Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to get an Image on the system clipboard?



Hi all,

I'm wondering if anyone has had any success putting a java.awt.Image onto the system clipboard (success being defined as you can then paste that image into other applications)?

I've tried a number of ways with no luck. First I tried using the Quicktime for Java classes to convert my image data into a PICT byte array stream as follows:

** Note: imgData is a byte array of PNG data
---
// imgData is a byte array of PNG data
QTHandle inHandle= new QTHandle(imgData);
QTHandle outHandle= new QTHandle();
GraphicsExporter ge= new GraphicsExporter(QTUtils.
toOSType("PICT"));
ImageDescription id= new ImageDescription(QTUtils.
toOSType("png "));
ge.setInputHandle(inHandle, id);
ge.setOutputHandle(outHandle);

if (ge.canTranscode()) {
ge.doTranscode();
o= new ByteArrayInputStream(outHandle.getBytes());
}
---

After that, o is put into a Transferable object which supports a custom DataFlavor with MIME type "image/x-pict" and copied to the system clipboard. I also tried putting the byte array and a Pict object on the clipboard in the same scenario with no luck.

Then I tried the more straightforward approach of using the DataFlavor.imageFlavor and putting the Image object itself on the clipboard.

So my question is, what do I need to put on the clipboard from my Java app so that native applications will get an image?

Thanks for any help,
Gord
_______________________________________________
java-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/java-dev
Do not post admin requests to the list. They will be ignored.




Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.