1Password / arboard

A clipboard for Rust

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Retrieving an image from the clipboard and saving it results in pixel distortion

zibo-chen opened this issue · comments

image

After retrieving the image from the clipboard, I loaded it with the image library and saved it as a PNG, and there are misplaced pixels in the bottom left corner.

The pixels on the right side of the image have also moved to the left.

Hi, thanks for opening this issue.

Can I ask what OS (and desktop environment, if applicable) you are seeing this issue in?

This issue can be reproduced on both Windows 10 and Windows 11.

I think I'm facing the same issue with arboard 3.3.1. This happens on Windows 10 if I place an image into the clipboard using a bit of C#; I believe this doesn't happen if I use, let's say, Copy image in Chrome.

I noticed one curious thing: if a distorted image has 1px height (no matter the width), it will always start as [255, 0, 0, 0, 0, 255, 0, 0, 0, 0, 255, 0]. This very 12 bytes. If, however, the image has a shape of square/rectangle/whatever, the distorted bytes are going to be somewhere in the middle.

This is how bytes look for a 14x1 red line (<byte number>. <pasted byte> -- <original byte> <match_or_not>):

14x1_red_line

And this is how it looks for a 10x10 red square:

10x10_red_square

I have found a reliable way to reproduce the pixel distortion issue when saving an image from the clipboard.

Steps to reproduce:

Ensure that Hyper-V is enabled on your Windows 10 or Windows 11 system.
Connect to a virtual machine using Hyper-V.
Use the built-in snipping tool of Windows 10 to take a screenshot.
Copy the screenshot to the clipboard.
Following these steps, the bug can be consistently reproduced both on Windows 10 and Windows 11 environments. It seems that the issue might be related to how the snipping tool interacts with the clipboard when Hyper-V is active, or how the clipboard data is being handled by the system in this specific virtualized context.

I hope this information helps in narrowing down the cause of the bug and finding a solution.