Jump to content

Copy/Paste image offset three pixels when pasted into Paint Tool SAI


Recommended Posts

That method you link to is decode a CF_DIB, not a CF_DIBV5. Notice how on line 814 it's specifically requesting CF_DIB.

 

CF_DIB is supposed to have the 3 mask values after the header. CF_DIBV5, which uses BITMAPV5HEADER, does not -- they are contained within the header itself.

 

Paint.NET places both a CF_DIBV5 and a CF_DIB on the clipboard. CF_DIBs cannot have transparency because there's no way to encode that information in the BITMAPINFOHEADER. So the CF_DIB placed on the clipboard by Paint.NET is a 24-bit BGR bitmap that has been blended on top of white. It specifies BI_RGB for biCompression, which means there is no color table after the header.

 

The CF_DIBV5 that Paint.NET places on the clipboard does have transparency, and it follows the rules for CF_DIBV5 / BITMAPV5HEADER. The bV5ClrUsed field is set to 0, which means that the color table after that struct has 0 length. The documentation erroneously states that "bmiColors" needs to have the 3 masks -- but bmiColors is part of BITMAPINFO, which contains BITMAPINFOHEADER + bmiColors, which places bmiColors in the same layout position as BITMAPV5HEADER's bV5___Mask fields.

 

When reading a CF_DIBV5 from the clipboard, Paint.NET tries to support both the correct and incorrect layouts.

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

Windows is the ultimate argument when we are writing for Windows, right? Two standard features of Windows, PrintScreen and Clipboard Viewer, DO ADD or DO REQUIRE these 12 bytes.

I found another argument. Maybe I’ll try, but not today, I’m a bit sick and keeping energy for my main job.

Windows automatically synthesizes other formats, so I’ll try to copy as DIBv5 and paste as DIB. If this DIBv5 gives incorrect DIB, or Windows refuses to convert at all — what’s else?

Edited by Mercury13
spelling
Link to comment
Share on other sites

I mean, for some reason this software REQUIRES these twelve bytes and shifts image data:

  • XnView
  • WinXP Clipboard viewer
  • Firefox
  • and Paint Tool SAI, as someone said

This software CREATES these twelve bytes:

  • Win10 screenshot feature

Maybe not everyone rides the wrong lane, but you do, as Russian joke says?

Edited by Mercury13
spelling
Link to comment
Share on other sites

6 hours ago, Mercury13 said:

If Windows is not an argument, what’s an argument?

 

Windows is an argument, that's fine, just remember this is a very complicated space due to the poor documentation and inconsistent implementations everywhere.

 

I'm willing to change my code if I'm presented with concrete proof/evidence that it needs to change, but the bar is high because it can have unintended cascading effects on users. I'm not saying you haven't presented concrete proof/evidence, but it does need very careful consideration and evaluation.

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

Krita does not include the extra 12 bytes when copying a 32-bit BGRA bitmap to the clipboard.

 

At this point, apps need to inspect the size of the data minus the value specified in bV5SizeImage. If it equals bV5Size (124 for BITMAPV5HEADER) then the 3 erroneous masks are not included. If it equals bV5Size+12, then it does. 

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

  • 2 months later...
On 11/26/2023 at 2:58 AM, Rick Brewster said:

@AndersM might have some extra insight, if he's got notifications enabled for mentions

I didn't 🙂  - but I have now.

 

I don't really have anything to add beyond what was discussed in the Graphics32 vs Paint.NET thread; My position is still that the three color masks are included in BITMAPV5HEADER and thus should not be added after the header. I.e. Paint.NET is correct.

 

  • Upvote 2
Link to comment
Share on other sites

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...