Clipboard Transparency

Hello.

I have a problem with the System Clipboard.
I have a BufferedImage with type

BufferedImage.TYPE_INT_ARGB

I use the following for copying the BufferedImage to the systems clipboard:

TransferableImage trans = new TransferableImage(sc);
Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard();
c.setContents(trans, this);

with TransferableImage implementing Transferable.
When I try to paste the image in a program like PowerPoint for example,
all that should be transparent is black.
But when I save the image by

ImageIO.write(image, "png", file);

it still has its transparent parts.
So my question is:
Where is the transparency lost and how can I prevent that from happening ?

It very much looks like Java/AWT does not support transparency in clipboard images.
And that seems to be because there is no standard way of handling transparency that would work with every application at least on Windows.
Look at this interesting thread: http://stackoverflow.com/questions/15689541/win32-clipboard-and-alpha-channel-images

Thank you KaiHH. :slight_smile:

The thread you posted is actually really interesting for me, especially since I already
searched the net for solutions and only found another stackoverflow thread, that wasn’t helpful at all.
I read through all of it and I’ll think I can use one of the solutions shown there.
I know it’s already two months later and you replied very fast and I didn’t look for a reply since then
nor did I get an automatic email…
I’m glad you answered and I write again when my program works the way it should :wink:

It didn’t get me any further… :-
I tried all kinds of formats and still don’t get what I need for some of the office tools.
Pasting an image with alpha channel into gimp and copying and pasting from gimp to office works fine.
And copying into java clipboard and pasting from there into office again doesn’t work at all…
I think there’s no easy way to solve this with only my java application.

That is true. The referenced stackoverflow thread mentions how to “solve” this problem via platform-specific Win32 API.
If you feel like giving that a try you could program against the Win32 API with JNA.
Or if you want it hard-core, you can of course write your own little JNI library.