Copy to Clipboard IOException (ARGB channel no longer supported for JPEGs)

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Post Reply
Posts: 5
Joined: Wed Apr 20, 2016 8:37 am
antibot: No, of course not.

Copy to Clipboard IOException (ARGB channel no longer supported for JPEGs)

Post by lynnskii » Fri May 24, 2019 11:37 pm

I'm in the process of migrating my applications to OpenJDK 11, I've discovered that copying a ChartPanel image to the WIndows clipboard now gives an IOException: Registered service providers failed to encode BufferedImage@228e6026: type = 2 DirectColorModel: rmask=ff0000 gmask=ff00 bmask=ff amask=ff000000 IntegerInterleavedRaster: width = 765 height = 420 #Bands = 4 xOff = 0 yOff = 0 dataOffset[0] 0 to image/jpeg
at java.desktop/sun.awt.datatransfer.DataTransferer.imageToStandardBytesImpl(
at java.desktop/sun.awt.datatransfer.DataTransferer.imageToStandardBytes(
at java.desktop/
at java.desktop/sun.awt.datatransfer.DataTransferer.translateTransferable(
at java.desktop/
at java.desktop/
at java.desktop/sun.awt.datatransfer.SunClipboard.setContents(
at org.jfree.chart.ChartPanel.doCopy(

Have done some research, it seems that the alpha channel of the JPEG image is no longer supported in the OpenJDK implementation.

I've tracked it down to org.jfree.chart.ChartTransferable.ChartTransferable.createBufferedImage(…)
BufferedImage image = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);

If BufferedImage.TYPE_INT_ARGB is replaced by BufferedImage.TYPE_INT_RGB, it works. Not sure if there are any other places with similar issues.

Here are some links from my research: ... issues/685
Apparently, the clipboard converts the image into JPG format instead of PNG as the menu item promises. As you would expect, the stack trace vanishes if the image type BufferedImage.TYPE_INT_RGB is used to prepare the image for transfer. The visual result doesn't differ.
JDK-8204187 removed support for ARGB channel for JPEG. Test uses ARGB input to encode JPEG image and we get IOException.

Post Reply