Open matwachich opened 1 year ago
According to the doc of Write: Write writes a given buffer to the clipboard in a specified format. Write returned a receive-only channel can receive an empty struct as a signal, which indicates the clipboard has been overwritten from this write. If format t indicates an image, then the given buf assumes the image data is PNG encoded.
Euh yes, I don't understand yet what I did wrong in my code.
I decode a jpeg into an image.Image, then I re-encode it to PNG in a bytes.Buffer, and I write this buffer to the clipboard and to a file to compare.
The written file is good, but clipboard's content is screwed.
Which clipboard receiver are you using on Windows? Are you using the system built-in clipboard? (On Windows, use Shift+Win+s) I remember from Windows; it might be problematic because there is an implicit agreement between the content writer and content receiver.
I just past clipboard content inside paint.exe. I don't use any non standard clipboard.
I think the implicit agrement is that the data is a PNG encoded data/file?
I experience the same issue, no matter what image I use, and if it's png encoded or not, the final image which I paste from the clipboard is corrupt. if I write it to file instead, the image is normal png image. I guess that windows expects for BMP and not PNG or someting like that.
When executing this on windows, the PNG on disk is good, but the one on clipboard is bad
Source JPEG
Here is the resulting PNG in clipboard