tags:

views:

129

answers:

1

If we drag or copy an image with alpha channel to a application / clipboard it lose the alpha channel using Qt. Using: QImage clipImage = pMimeData->imageData().value();

gives us 32 bit image with black background where it suppose to be transparent. The format of an image is always QImage::Format_RGB32. I tried to convert it to QImage::Format_ARGB32_Premultiplied and to extract the alpha channel but I received for alpha channel only black background which covers the whole portion of image. Howe can I retrieve the correct image with correct alpha channel from QMimeData.

Cheers Dejan

A: 

This is not an easy question to answer, not all application accept images with an alpha channel. I tried sending a PNG image via the clipboard (because it supports transparency) and that failed due to MS office not having a standard PNG clipboard import.

http://stackoverflow.com/questions/1260253/how-do-i-put-an-qimage-with-transparency-onto-the-clipboard-for-another-applicati

We have had to develop an interface which interacts with the MS Office API to insert the image. However could you be specific as to your destination application?

I asked Qt and they sort of said it was working as expected, its the receiving application that needs fixing.

Phil Hannent
If I copy the PNG image with alpha channel to a clipboard and then using QClipboard and QMimeData to extract it to my app I receive data back using QMimeData::imageData().value<QImage>(); but that image is flattened without alpha channel. If I try to use QMimeData::data("application/x-qt-image") it returns me an empty QByteArray even if QMimeData::formats().contains("application/x-qt-image") returns true. Using native Pasteboard on Mac and retrieve data to CGImageRef the image is of correct format and with alpha channel which makes me think that there is a bug in QClipboard.CheersDejan
And I have tried with MS Office 2008 for MAC and it accepts PNG with alpha channel from clipboard just fine.CheersDejan