Changing the JPG color parameters in javax.imageio

Discussion in 'Java' started by Chris Berg, Jul 13, 2005.

  1. Chris Berg

    Chris Berg Guest

    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
     
    Chris Berg, Jul 13, 2005
    #1
    1. Advertising

  2. On Wed, 13 Jul 2005 23:37:21 +0200, Chris Berg wrote:

    > 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>

    --
    Andrew Thompson
    physci.org 1point1c.org javasaver.com lensescapes.com athompson.info
    It's Like "Hee Haw" With Lasers
     
    Andrew Thompson, Jul 15, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. F C
    Replies:
    2
    Views:
    5,162
  2. Patrick
    Replies:
    1
    Views:
    735
  3. Davidski
    Replies:
    0
    Views:
    3,892
    Davidski
    Nov 5, 2004
  4. Rune
    Replies:
    4
    Views:
    1,838
  5. Kamaljeet Saini
    Replies:
    0
    Views:
    431
    Kamaljeet Saini
    Feb 13, 2009
Loading...

Share This Page