"Crop to selection" can enlarge image

Bug #606245 reported by Maia Everett
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Pinta
Fix Released
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.

Revision history for this message
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?

Revision history for this message
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

Revision history for this message
Jonathan Pobst (jpobst) wrote :
Changed in pinta:
importance: Undecided → Medium
milestone: none → 0.6
status: New → Fix Committed
Revision history for this message
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)
Changed in pinta:
milestone: 0.6 → 0.8
grofaty (grofaty)
Changed in pinta:
status: New → Confirmed
Revision history for this message
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...

Revision history for this message
Olivier Dufour (olivier-duff) wrote :

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

Revision history for this message
Jonathan Pobst (jpobst) wrote :
Changed in pinta:
status: Confirmed → Fix Committed
Revision history for this message
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  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.