views:

398

answers:

2

Using Delphi 2010 I would like to copy a PNG image to the clipboard while preserving the alpha transparency. Unfortunately, the TPngImage.SaveToClipboardFormat method will draw it to a bitmap and the transparency will be lost.

I would like for the PNG image to be pasted in applications such as Photoshop and Word with alpha transparency.

Any idea on how to do that ? How are other applications doing to copy transparency in the clipboard ?

+2  A: 

It could be that they use an alternative clipboard format, see http://msdn.microsoft.com/en-us/library/ms649013(VS.85).aspx for a list of available clipboard formats. Or they could register their own clipboard format such as

RegisterClipboardFormat('PNG') 

and then simply write the png data to the clipboard. If the clipboard format string specified is standard (i.e. other applications register the same clipboard format) then you will be able to paste it into other applications which support this clipboard format.

You might need to call windows functions directly as Delphi's clipboard wrapper isn't very good.

JamesB
+2  A: 

I'd first copy an image with transparency information to the clipboard in Photoshop, and then examine what's actually on the clipboard. When you know this, you can probably figure out how to write that data yourself.

Frederik Slijkerman