"Crop to selection" can enlarge image

Bug #606245 reported by Maia Everett on 2010-07-16
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Pinta
Medium
Unassigned

Bug Description

If, when selecting, the mouse goes outside the canvas, the selection is displayed as if it is restricted by the canvas, but internally it is not. The "Crop to selection" operation can enlarge the canvas, adding the invisible off-canvas areas that were selected. Additionally, zooming out after such "cropping" is performed sometimes throws an exception.

Jonathan Pobst (jpobst) wrote :

I guess the issue here is to ensure the selection doesn't go outside the canvas. I cannot reproduce that, do you remember how you got it to do that?

magic3 (magic3) wrote :

I have a similar problem with Pinta 0.5.
If I start a selection outside the image, then crop or copy it, I get a larger image with trasparency where there isn't image.

The bug is in the selection and not with the function "Crop to selection". I get the same problem if I just copy and paste the selection somewhere.

I get the problem only with rectangular select and ellipse select

Jonathan Pobst (jpobst) wrote :
Changed in pinta:
importance: Undecided → Medium
milestone: none → 0.6
status: New → Fix Committed
grofaty (grofaty) wrote :

I have installed Pinta 0.7 on Windows XP sp3 and I can reproduce the problem in comment 3:
1. Create new image 100x100 pixels.
2. Select Rectange Select tool from Tools.
3. Start selecting the image outside of the canvas (in my case at left-top site but outside of the canvas).
4. Canvas is market with selection (see left site of attached picture).
5. Click on Crop to Selection button from toolbar.
The image is cropped but at the right site and bottom there is transparent area displayed.

Changed in pinta:
status: Fix Committed → New
Jonathan Pobst (jpobst) on 2011-03-08
Changed in pinta:
milestone: 0.6 → 0.8
grofaty (grofaty) on 2011-03-08
Changed in pinta:
status: New → Confirmed
Olivier Dufour (olivier-duff) wrote :

easy fix in selectTool.cs
iin OnMouseDown
- shape_origin = point;
+ // Selection is around the pixel selection so add 1 pixel
+ double x = Utility.Clamp (point.X, 0, doc.ImageSize.Width);
+ double y = Utility.Clamp (point.Y, 0, doc.ImageSize.Height);
+ shape_origin = new PointD (x, y);

OnMouseMove

- double x = Utility.Clamp (point.X, 0, doc.ImageSize.Width - 1);
- double y = Utility.Clamp (point.Y, 0, doc.ImageSize.Height - 1);
+ double x = Utility.Clamp (point.X, 0, doc.ImageSize.Width);
+ double y = Utility.Clamp (point.Y, 0, doc.ImageSize.Height);

because size an origin was miss clamped...

Olivier Dufour (olivier-duff) wrote :

my patch was not right. But I have a new one. I will send a pull request soon.

Jonathan Pobst (jpobst) wrote :
Changed in pinta:
status: Confirmed → Fix Committed
grofaty (grofaty) wrote :

I have installed Pinta 0.8 on Windows xp sp3 and I have tested the case from comment 4 and now the problem is solved.

Changed in pinta:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers