Win32: Alpha channel clipboard format

Bugs found in XnView Classic. Please report only one bug per topic!

Moderators: XnTriq, helmut, xnview

Post Reply
andy82
Posts: 3
Joined: Fri Mar 29, 2013 11:02 am

Win32: Alpha channel clipboard format

Post by andy82 »

Hi,

when copying a PNG that contains an alpha channels to the clipboard with XnView the pixel data is not premultiplied by the alpha channel. When I copy the same PNG to the clipboard using Firefox or Chrome, however, the pixel data is premultiplied by the alpha channel data. AFAIK there is no official consensus as to whether or not pixel data should be premultiplied but if Firefox and Chrome do it, it might be considered an unofficial standard and maybe XnView should be adapted to premultiply as well.

See here for a further discussion on alpha channel data in the clipboard:
http://stackoverflow.com/questions/1568 ... nel-images

Tks

EDIT: Also, XnView doesn't seem to support the alpha channel when pasting an image. It always appears opaque.
User avatar
xnview
Author of XnView
Posts: 43326
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

Re: Win32: Alpha channel clipboard format

Post by xnview »

Hi,
You want to copy in which software?
andy82 wrote: EDIT: Also, XnView doesn't seem to support the alpha channel when pasting an image. It always appears opaque.
Copied from which software?
Pierre.
andy82
Posts: 3
Joined: Fri Mar 29, 2013 11:02 am

Re: Win32: Alpha channel clipboard format

Post by andy82 »

You want to copy in which software?
Actually I want to copy to my own software. But transparency is also lost when pasting into Word 2010 or Paint.NET, for instance. My own software looks for a CF_DIBV5 on the clipboard and when the data comes from XnView, then the colors aren't premultiplied. When the data comes from Firefox or Chrome, the colors are premultiplied so I think XnView should premultiply as well.
Copied from which software?
From XnView itself :-) Just try it: Open a alpha channel PNG in XnView, copy it to the clipboard, open another image and try to paste the clipboard image... you'll see that transparency is gone now!

Note that there seems no official way of dealing with alpha channel data in clipboards. We recently discussed this in detail on StackOverflow:
http://stackoverflow.com/questions/1568 ... nel-images
User avatar
xnview
Author of XnView
Posts: 43326
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

Re: Win32: Alpha channel clipboard format

Post by xnview »

andy82 wrote:
You want to copy in which software?
Actually I want to copy to my own software. But transparency is also lost when pasting into Word 2010 or Paint.NET, for instance. My own software looks for a CF_DIBV5 on the clipboard and when the data comes from XnView, then the colors aren't premultiplied. When the data comes from Firefox or Chrome, the colors are premultiplied so I think XnView should premultiply as well.
Strange, i've checked, and i don't export in CF_DIBV5 only CF_DIB
Copied from which software?
From XnView itself :-) Just try it: Open a alpha channel PNG in XnView, copy it to the clipboard, open another image and try to paste the clipboard image... you'll see that transparency is gone now!

Note that there seems no official way of dealing with alpha channel data in clipboards. We recently discussed this in detail on StackOverflow:
http://stackoverflow.com/questions/1568 ... nel-images
right the same problem with clipboard...

Please contact me by email...
Pierre.
andy82
Posts: 3
Joined: Fri Mar 29, 2013 11:02 am

Re: Win32: Alpha channel clipboard format

Post by andy82 »

Strange, i've checked, and i don't export in CF_DIBV5 only CF_DIB
That's normal. Windows does automatic format conversion between several clipboard formats. So if an app requests CF_DIBV5 but there is only a CF_DIB on the clipboard, Windows will convert it automatically.

See "Synthesized clipboard formats" here:
http://msdn.microsoft.com/en-us/library ... 85%29.aspx
Please contact me by email...
Email sent.
User avatar
xnview
Author of XnView
Posts: 43326
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

Re: Win32: Alpha channel clipboard format

Post by xnview »

andy82 wrote: Email sent.
do you have received my reply?
Pierre.
simoncbs
Posts: 1
Joined: Thu Apr 04, 2013 1:29 pm

Re: Win32: Alpha channel clipboard format

Post by simoncbs »

Hi, I'm a long time reader, but this topic has finally prompted me to register, so here goes...

I have always struggled with 32-bit copy/paste, and I still use v1.97.8 as this is the last version that I can make it work in.

v1.97.8
32-bit Copy / Paste: works OK (as long destination image is also 32-bit)
32-bit Copy / Import clipboard: clipboard imported as 24-bit (without alpha layer), but then you can convert the newly created image to 32-bit, and paste the clipboard over it again, and now it works.

v1.98-v1.99
Neither of the above work for me (on XP SP3), I have tried every combination of alpha/32-bit settings I can find, and I just cannot get 32-pasting to work by any means.

I assume that the problem occurs in the pasting, not the copying, as I can copy from 1.98/99 then paste this into 1.97,
but I cannot copy (successfully) from 1.97 into 1.98/99.

Now for some l-o-n-g overdue gratitude - thank you Pierre, I have used XnView for years and would be lost without it, and also to all the others who contribute to XnView and this forum.
Cheers, Simon.

UPDATE: Thank-you, the new v2.0.0 fixes these issues completely.
btakacs
Posts: 15
Joined: Fri Mar 29, 2013 2:14 pm

Re: Win32: Alpha channel clipboard format

Post by btakacs »

XnView doesn't seem to support the alpha channel when pasting an image. It always appears opaque.
For me this is still an issue. I opened my transparent png directly from Word and then copy-pasted through selection and clipboard (XnView 2.0.4 in Win 7).

You can see the original image in XnView and the two versions in Word:
Image

(1) opened directly from Word and (2) selected and copied through clipboard
User avatar
xnview
Author of XnView
Posts: 43326
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

Re: Win32: Alpha channel clipboard format

Post by xnview »

could you send me the file used?
Pierre.
Post Reply