By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,034 Members | 819 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,034 IT Pros & Developers. It's quick & easy.

How turn cmyk jpeg into rgb using Java?

P: n/a
How can I load a CMYK jpeg image (originally saved from Photoshop) and then
turn it into an rgb BufferedImage, in order to display it on screen in an

I first tried, but that does not work for cmyk jpegs. I then
looked into the com.sun.image.codec.jpeg package, and tried methods like
decodeAsBufferedImage() and decodeAsRaster().

The first one (decodeAsBufferedImage) returned an image, but it seems that
it was interpreted as an ARGB, and the colors were incorrect.

I then read the documentation which (amongst many other things) stated that
"If the user needs better control over conversion, the user must request the
data as a Raster and handle the conversion of the image data themselves."
This made sense, so I took to decodeAsRaster(), only to find that I could
not figure out how to carry out the desired conversion.

Of course, I have looked into the documentation for BufferedImage, Raster,
ColorModel, ColorSpace etc, but after a while I was lost. (Before I got lost
I read that you can convert images with the help of methods like toRGB,

I have a feeling that this is probably pretty simple if you just know how to
do it, but I sure would need some directions here.

Any help would be appreciated. Thanks.

Mats Olsson
Jul 17 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.