How do I cut and paste a Java Image to a an external program like Microsoft Paint?

Sandip Chitale

As of today - no you can't :( in 100% pure Java. That is because of the following bug and other related bugs -

You can do that using JNI though. It can be done on MS Windows platform using the following strategy -

Use the java.awt.image.PixelGrabber class to convert the Java Image into a DIB or BMP format array ( the formats used to transfer images on the MS Windows platform). Then pass it to the JNI function which use the following APIs -


GlobalAlloc( buffer)
GlobalLock( buffer)
// copy image header and data to the buffer
// you wil have to deal with byte and RGB pixel order here


0 Comments  (click to add your comment)
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



About | Sitemap | Contact