Jump to content

Paste Problem


BoltBait

Recommended Posts

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.

Link to comment
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.

Link to comment
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.

The Paint.NET Blog: https://blog.getpaint.net/

Donations are always appreciated! https://www.getpaint.net/donate.html

forumSig_bmwE60.jpg

Link to comment
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.

Link to comment
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 #.

The Paint.NET Blog: https://blog.getpaint.net/

Donations are always appreciated! https://www.getpaint.net/donate.html

forumSig_bmwE60.jpg

Link to comment
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?

Link to comment
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.

The Paint.NET Blog: https://blog.getpaint.net/

Donations are always appreciated! https://www.getpaint.net/donate.html

forumSig_bmwE60.jpg

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...