image > copy, adds 3 white pixels on the left, deletes 3 pixels on the right #118351

Closed
opened 2024-02-15 22:58:27 +01:00 by LOIC BRAMOULLE · 11 comments

System Information
Operating system: Windows-10-10.0.19045-SP0 64 Bits
Graphics card: NVIDIA GeForce RTX 3090/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 546.01

Blender Version
Broken: version: 3.6.4, branch: blender-v3.6-release, commit date: 2023-09-25 13:24, hash: 21bfc5e7fe3f
Worked: (newest version of Blender that worked as expected)

Short description of error
image > copy, adds 4 white pixels on the left, deletes 4 pixels on the right

Exact steps for others to reproduce the error
1 - render anything.
2 - in render result go Image > copy, then paste in photoshop.
3 - you will have a 3 pixels line added on the left, and 3 pixel line missing on the right, shifting the whole image 3 pixels to the right basically.

**System Information** Operating system: Windows-10-10.0.19045-SP0 64 Bits Graphics card: NVIDIA GeForce RTX 3090/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 546.01 **Blender Version** Broken: version: 3.6.4, branch: blender-v3.6-release, commit date: 2023-09-25 13:24, hash: `21bfc5e7fe3f` Worked: (newest version of Blender that worked as expected) **Short description of error** image > copy, adds 4 white pixels on the left, deletes 4 pixels on the right **Exact steps for others to reproduce the error** 1 - render anything. 2 - in render result go Image > copy, then paste in photoshop. 3 - you will have a 3 pixels line added on the left, and 3 pixel line missing on the right, shifting the whole image 3 pixels to the right basically.
LOIC BRAMOULLE added the
Priority
Normal
Type
Report
Status
Needs Triage
labels 2024-02-15 22:58:28 +01:00
Member

Hi, thanks for the report. I'm not able to confirm this in 4.1/3.6
Not sure if render/output setting would make the difference here. Can you attach .blend where problem is visible?
Did you try pasting the image in other software? I tried in ms-paint and blender itself btw :)

Hi, thanks for the report. I'm not able to confirm this in 4.1/3.6 Not sure if render/output setting would make the difference here. Can you attach .blend where problem is visible? Did you try pasting the image in other software? I tried in ms-paint and blender itself btw :)
Pratik Borhade added
Status
Needs Information from User
and removed
Status
Needs Triage
labels 2024-02-16 07:08:33 +01:00
Author

Hi Pratik, damn, must come from my blender environment maybe, it happens on any blend file, and any program when pasting, apart from blender itself if I paste back as a new image. (but the 3 pixels are in PS, paint ect..)
Not a showstopper I can just save + open images if it's only me.
It's pretty strange it's actually the 3 far right pixels of the images that are slapped on the far left, effectlively sliding the image 3 pixel to the right. (so not a white line, but a re-order.)
image

Hi Pratik, damn, must come from my blender environment maybe, it happens on any blend file, and any program when pasting, apart from blender itself if I paste back as a new image. (but the 3 pixels are in PS, paint ect..) Not a showstopper I can just save + open images if it's only me. It's pretty strange it's actually the 3 far right pixels of the images that are slapped on the far left, effectlively sliding the image 3 pixel to the right. (so not a white line, but a re-order.) ![image](/attachments/e9276b78-fb13-44e9-a90f-d8b6c25c4ab3)

Yep, I can confirm the bug in 4.2 blender-4.2.0-alpha+main.d803b6acca19-windows.amd64-release

image

And yes, if you copy and then paste it in blender itself, the problem doesn't occur...

Yep, I can confirm the bug in 4.2 `blender-4.2.0-alpha+main.d803b6acca19-windows.amd64-release` ![image](https://projects.blender.org/attachments/e2680f98-7981-470b-af55-c713b6f51524) And yes, if you copy and then paste it in blender itself, the problem doesn't occur...
252 KiB
Author

if it helps, sometimes it's also 2 pixels vertically:
image

if it helps, sometimes it's also 2 pixels vertically: ![image](/attachments/02cf7fee-fce5-433c-9c3f-8e7fabffbc2b)

I'll confirm. I can reproduce in Krita, but not in Gimp - by default at least.

When Blender puts the image on the clipboard it does so in 2 different formats: the Windows DibV5 bitmap format and a regular PNG format which applications will then choose from on their own. If I change the code to only use PNG then Krita and Gimp work fine. If I use just DibV5 then both Krita and Gimp show the shifted pixels.

CC @Harley do you remember why DibV5 offsets by + 12 for the pixel data? This seems to be the issue in this case.

I'll confirm. I can reproduce in Krita, but not in Gimp - by default at least. When Blender puts the image on the clipboard it does so in 2 different formats: the Windows DibV5 bitmap format and a regular PNG format which applications will then choose from on their own. If I change the code to only use PNG then Krita and Gimp work fine. If I use just DibV5 then both Krita and Gimp show the shifted pixels. CC @Harley do you remember why DibV5 offsets by `+ 12` for the pixel data? This seems to be the issue in this case.
Jesse Yurkovich added
Status
Confirmed
and removed
Status
Needs Information from User
labels 2024-02-17 02:44:02 +01:00
Jesse Yurkovich added the
Module
User Interface
label 2024-02-17 02:45:04 +01:00
Member

@deadpin

There is something weird about the specification of that format and I'm probably just doing something wrong.

They define a header with all its members, but then tell you that if one member (bV5Compression) is set to BI_BITFIELDS then there is 3 dword mask values between the header and the bitmap.

When we GET that format from the clipboard I see that we are checking for that state and offsetting by 12 bytes. But when we PUT that format on the clipboard we do set that bV5Compression to BI_BITFIELDS (meaning no compression) and also do that offsetting.

Although when I am looking around for this I am not seeing this in Microsoft docs right now but only references to it in other peoples posts. So perhaps there is a difference with different versions of this structure - we are using V5, as in BITMAPV5HEADER so maybe this extra crap between header and data is only for an older version?

Sorry if you explained it well and I'm not getting it, but are we putting this format on the clipboard and others see it off by three pixels, or are we offsetting by three pixels when we read this format from others? As in are we broken coming in, going out, or both?

@deadpin There is something weird about the specification of that format and I'm probably just doing something wrong. They define a header with all its members, but then tell you that if one member (bV5Compression) is set to BI_BITFIELDS then there is 3 dword mask values between the header and the bitmap. When we GET that format from the clipboard I see that we are checking for that state and offsetting by 12 bytes. But when we PUT that format on the clipboard we do set that bV5Compression to BI_BITFIELDS (meaning no compression) and also do that offsetting. Although when I am looking around for this I am not seeing this in Microsoft docs right now but only references to it in other peoples posts. So perhaps there is a difference with different versions of this structure - we are using V5, as in BITMAPV5HEADER so maybe this extra crap between header and data is only for an older version? Sorry if you explained it well and I'm not getting it, but are we putting this format on the clipboard and others see it off by three pixels, or are we offsetting by three pixels when we read this format from others? As in are we broken coming in, going out, or both?
Member

The following is a discussion of similar problem with Paint.net with their main dev looking like he read the spec like I did and did it wrong too. This comment from a MS employee looks to explain it well,

The V1 version of that structure had this optional extra 12 bytes, but then those became part of the structure later. The docs just don't explain that well:

https://forums.getpaint.net/topic/122848-pasting-dibv5-image/#comment-610918

But even his comment ends with "Now, even though I claim my interpretation of the structures to be "the right one" it can also be argued that they are both correct. The documentation has been changed so many times with regard to this and it's still broken, some parts of Windows write one variant, other parts write another and it can usually read them both."

The following is a discussion of similar problem with Paint.net with their main dev looking like he read the spec like I did and did it wrong too. This comment from a MS employee looks to explain it well, The V1 version of that structure had this optional extra 12 bytes, but then those became part of the structure later. The docs just don't explain that well: https://forums.getpaint.net/topic/122848-pasting-dibv5-image/#comment-610918 But even his comment ends with "Now, even though I claim my interpretation of the structures to be "the right one" it can also be argued that they are both correct. The documentation has been changed so many times with regard to this and it's still broken, some parts of Windows write one variant, other parts write another and it can usually read them both."
Member

@deadpin - If I change the code to only use PNG then Krita and Gimp work fine. If I use just DibV5 then both Krita and Gimp show the shifted pixels.

Oh, when I was testing this the latest version of Gimp at the time wouldn't use this format, if I remember right, which is why I started down the road of also placing PNG as that was the only other format supporting transfer of alpha. And I only had a very old version of Photoshop. So for this format I was only testing with Paint and Krita, but (hopefully) just missed noticing it was out by three pixels.

> @deadpin - If I change the code to only use PNG then Krita and Gimp work fine. If I use just DibV5 then both Krita and Gimp show the shifted pixels. Oh, when I was testing this the latest version of Gimp at the time wouldn't use this format, if I remember right, which is why I started down the road of also placing PNG as that was the only other format supporting transfer of alpha. And I only had a very old version of Photoshop. So for this format I was only testing with Paint and Krita, but (hopefully) just missed noticing it was out by three pixels.
Member

@deadpin - If I use just DibV5 then both Krita and Gimp show the shifted pixels.

Yes, seems to test out well. But for testing I have to alter the code to ensure that only the formats I want to test are used, with breakpoints set to confirm.

  • Load image into Gimp 2.10.36

  • Copy and Paste to Blender (as DibV5)

  • Copy and Page to new layer in Gimp (as DibV5)

  • These layers show 3 pixel shift

  • Load image into Gimp 2.10.36

  • Copy and Paste to Blender (as PNG)

  • Copy and Page to new layer in Gimp (as DibV5)

  • These layers show 3 pixel shift

But, weirdly, If load an image in Krita, then copy to Gimp and also copy to Blender (as DibV5). Then copy and paste from Blender to a new layer in Gimp (as DibV5) they are perfectly aligned. But then copy and paste from Gimp to Blender and back as new layer and they are misaligned.

So far have managed to recreate the issue with Gimp, but not with Krita. But removing those 12 bytes it fixes the issue with Gimp and does not cause any errors with Krita.

This, and my (new) reading of the spec based on what that MS guy is saying, seems like a lock.

Although I don't have a new version of Photoshop to test DibV5 transfers the error I see with Gimp exactly matches what is described with Photoshop.

> @deadpin - If I use just DibV5 then both Krita and Gimp show the shifted pixels. Yes, seems to test out well. But for testing I have to alter the code to ensure that only the formats I want to test are used, with breakpoints set to confirm. * Load image into Gimp 2.10.36 * Copy and Paste to Blender (as DibV5) * Copy and Page to new layer in Gimp (as DibV5) * These layers show 3 pixel shift * Load image into Gimp 2.10.36 * Copy and Paste to Blender (as PNG) * Copy and Page to new layer in Gimp (as DibV5) * These layers show 3 pixel shift But, weirdly, If load an image in Krita, then copy to Gimp and also copy to Blender (as DibV5). Then copy and paste from Blender to a new layer in Gimp (as DibV5) they are perfectly aligned. But then copy and paste from Gimp to Blender and back as new layer and they are misaligned. So far have managed to recreate the issue with Gimp, but not with Krita. But removing those 12 bytes it fixes the issue with Gimp and does not cause any errors with Krita. This, and my (new) reading of the spec based on what that MS guy is saying, seems like a lock. Although I don't have a new version of Photoshop to test DibV5 transfers the error I see with Gimp exactly matches what is described with Photoshop.
Blender Bot added
Status
Resolved
and removed
Status
Confirmed
labels 2024-02-17 20:29:57 +01:00
Member

Broken: version: 3.6.4, branch: blender-v3.6-release

Given 3.6 is affected, can we add your fix in 3.6 backporting list? @Harley

And thanks for confirming and fixing this report. I usually don't check bug reports during weekend 😅

> Broken: version: 3.6.4, branch: blender-v3.6-release Given 3.6 is affected, can we add your fix in 3.6 backporting list? @Harley And thanks for confirming and fixing this report. I usually don't check bug reports during weekend 😅
Member

@PratikPB2123 - Given 3.6 is affected, can we add your fix in 3.6 backporting list?

I just added this to that list.

> @PratikPB2123 - Given 3.6 is affected, can we add your fix in 3.6 backporting list? I just added this to [that list](https://projects.blender.org/blender/blender/issues/109399).
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
5 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#118351
No description provided.