Skip to content

Commit e2b9ec4

Browse files
committed
fix how the canvas was ERASED when cropping/expanding in a certain way
it impacts #332 but this issue existed before
1 parent f45bb38 commit e2b9ec4

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

debian/changelog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
drawing (0.8.1) unstable; urgency=low
22

33
* add an action "selection > define as current image" (#332)
4+
* fix how the canvas was ERASED if it was being cropped on one side but expanded on the other side
45
* add an action "selection > expand image to fit [the size of the selection]" (#332)
56
* add a several ways of censoring information as an option to the eraser tool
67
* preference to select a theme variant (#360, #361, by @alexislozano)

src/tools/transform_tools/tool_crop.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -240,23 +240,27 @@ def do_tool_operation(self, operation):
240240
else:
241241
source_pixbuf = self.get_main_pixbuf()
242242
self.get_image().set_temp_pixbuf(source_pixbuf.copy())
243-
self.crop_temp_pixbuf(x, y, width, height, is_selection, rgba)
243+
self._crop_temp_pixbuf(x, y, width, height, is_selection, rgba)
244244
self.common_end_operation(operation)
245245

246-
def crop_temp_pixbuf(self, x, y, width, height, is_selection, rgba):
247-
new_pixbuf = GdkPixbuf.Pixbuf.new(GdkPixbuf.Colorspace.RGB, True, 8, width, height)
248-
new_pixbuf.fill(rgba)
246+
def _crop_temp_pixbuf(self, x, y, width, height, is_selection, rgba):
249247
src_x = max(x, 0)
250248
src_y = max(y, 0)
249+
251250
if is_selection:
252251
dest_x = 0
253252
dest_y = 0
254253
else:
255254
dest_x = max(-1 * x, 0)
256255
dest_y = max(-1 * y, 0)
256+
257+
new_pixbuf = GdkPixbuf.Pixbuf.new(GdkPixbuf.Colorspace.RGB, True, 8, width, height)
258+
new_pixbuf.fill(rgba)
259+
257260
temp_p = self.get_image().temp_pixbuf
258-
min_w = min(width, temp_p.get_width() - src_x)
259-
min_h = min(height, temp_p.get_height() - src_y)
261+
min_w = min(width - dest_x, temp_p.get_width() - src_x)
262+
min_h = min(height - dest_y, temp_p.get_height() - src_y)
263+
260264
temp_p.copy_area(src_x, src_y, min_w, min_h, new_pixbuf, dest_x, dest_y)
261265
self.get_image().set_temp_pixbuf(new_pixbuf)
262266

0 commit comments

Comments
 (0)