Sign in to follow this  
Followers 0
BoltBait

Paste Problem

13 posts in this topic

I opened a new graphic today using Paint.NET 3.5.6.

I had just flattened an image. Then, I selected a middle portion of the graphic 78x30 pixels, adjusted what was selected with the move selection tool, and pressed Ctrl-C. Then I immediately pressed Ctrl-Alt-V to paste into a new image.

The resulting image was 79x30 with an extra column of transparent pixels down the right edge.

Still looking at the new image, I pressed Ctrl-V to paste what was on the clipboard again... this time it came out right: the image was fully selected and the line of transparent pixels was not selected. I hit the crop button to fix the new graphic and all was well.

I was cutting out buttons from a big image and creating individual button images.

This happened twice in a row (the first two buttons) then did not happen for the third or fourth. Starting the next row, it happened again.

It is not happening every time, and sometimes the extra row of pixels is at the bottom. Does it depend on what edge was adjusted last using the move selection tool?

I'm on Windows XP. Enjoy.

0

Share this post


Link to post
Share on other sites

How did you create the initial 78x30 selection?

0

Share this post


Link to post
Share on other sites

By using the square selection tool. Nothing fancy there. I used :RectangleSelectTool: then :MoveSelectionTool: to fine tune what was selected, then Ctrl-C.

I find it interesting that there was a size difference between the Ctrl-V paste and the Ctrl-Alt-V paste. I would start by comparing code in those areas.

0

Share this post


Link to post
Share on other sites

I was zoomed in to 300% or 400% on the source image.

0

Share this post


Link to post
Share on other sites

Okay I know I fixed a few issues with discrepancies between selection and Paste, but apparently there are a few more. I'll file a bug for v3.5.x. Thanks.

0

Share this post


Link to post
Share on other sites

I'm just glad I could help.

0

Share this post


Link to post
Share on other sites

I'm going to take a guess here: using the Move Selection tool, you adjusted a corner edge while holding down the shift key. Does that sound right?

0

Share this post


Link to post
Share on other sites

I might have. I think I was adjusting the size of the selection using the middle handles.

It's been a while and I don't remember.

Plus, that system crashed and I'm rebuilding it.

I had one hard drive fail... of a raid 0 striped volume. :(

On the plus side, your usage graph for next period will have one less Windows 2003 Server user in it and one more Windows 2008 Server user in it.

0

Share this post


Link to post
Share on other sites

What I found is that the selection geometry object, which tracks things using double-precision floating point, is drifting by a tiny amount.

In this case that I'm looking at right now, the bounds are x=360.0, y=263.99999999999994 (thirteen 9's and a 4), width=60.0, height=16.901408450704253. All the code is correct from a mathematical standpoint, but that drift is what's causing an "extra" pixel on the edge. In this case it's on the top edge, on your's it was on the bottom.

Windows 7 and Server 2008 get lumped together. They have the same version #.

0

Share this post


Link to post
Share on other sites

Everything I've seen with Ctrl-V and Shift-Ctrl-V paste works fine. The problem is in Ctrl-Alt-V.

When you press Ctrl-Alt-V, Paint.NET creates a new canvas to contain the clipboard contents before the normal Ctrl-V paste happens. In this case, the Ctrl-V part works fine, but the Ctrl-Alt-V part creates a canvas that is too big.

My guess is that there is a rounding error happening in the Ctrl-Alt-V code that creates a new canvas. Brain storm: Are you using the same rounding techniques, in the same way? Are the data types different? Is a cast (or automatic cast) causing this?

0

Share this post


Link to post
Share on other sites

What's happening is a discrepancy between the geometry's bounding box, and the bounding box of the geometry's scan-conversion.

The geometry is, essentially, a System.Windows.Point[][]. That is, a list of double-precision (X,Y) pairs. A list of polygons.

The scan-conversion is the System.Windows.Int32Rect[] that approximates the interior of the polygon for a particular transformation (or rather, "at a specific resolution").

The geometry bounds end up being something like top=, 293.999999994. The scan-conversion correctly has a bound of 294.

In order to ensure that all pixels come along for the ride, the MaskedSurface class takes the Int32Bound of the geometry bounds -- which gives us top=293. (the "Int32Bound" of a Rect is simply "the smallest rectangle, using integer coordinates, that fits around this rectangle which uses floating point coordinates"). And then the PasteInToNewImage action is taking the size of that rectangle instead of the bounds of the scan-conversion.

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0