Changing the JPG color parameters in javax.imageio

C

Chris Berg

My server, which runs under Java 1.5 wants to convert a .png image
file to .jpg format, to be displayed by an Applet that runs under MS
Java 1.1 VM (IE). (which doesn't support .png).

I use

import javax.imageio.*;
ImageIO.write(ImageIO.read(inData), "jpg", outData);

where inData is an InputStream containing the png file, and outData is
an outputStream for the jpg. All goes well; the applet runs fine in
Java 1.5, but when I run it in 1.1, an exception occurs:

sun.awt.image.ImageFormatException: Unsupported color conversion
request
at
sun.awt.image.JPEGImageDecoder.produceImage(JPEGImageDecoder.java:125)
at sun.awt.image.InputStreamImageSource.doFetch(Compiled Code)
at sun.awt.image.ImageFetcher.fetchloop(Compiled Code)
at sun.awt.image.ImageFetcher.run(Compiled Code)

So, it appears that the JPG produced has a color model also not
supported by the MS VM. Strange, 'cause I have never encountered any
other jpg image that it didn't understand.

I also ran it in Sun's Java 1.1.8 Appletviewer by the way, and it
produced the same result.

I suppose i have to play with the javax.imageio.* classes to change
some settings, but it appears to be overwelmingly complicated. Sun's
tutorial also seems quite uninviting. Is it possible to create a JPG
image that the 1.1 applet can understand, without too much effort?


Chris
 
A

Andrew Thompson

My server, which runs under Java 1.5 wants to convert a .png image
file to .jpg format, ...
sun.awt.image.ImageFormatException: Unsupported color conversion

<shot in the monochrome>
Does the .png contain transparent or semi transparent colors?
</shot in the monochrome>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top