Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

javax.imageio package dies reading PNG file

2 views
Skip to first unread message

Robert Metzger

unread,
Jan 13, 2005, 6:07:25 PM1/13/05
to
I am unable to get PNG reading to work using the javax.imageio.ImageIO package.
I'm using PNG because ImageIO doesn't have a GIF writer
(I need to both read and write) and the JPEG writer blurs
my pictures in very ugly ways.

Here's my code:

File iconFile= null;
BufferedImage image= null;
try {
iconFile= new File(PATH_TO_IMAGE);
image= ImageIO.read(iconFile); // <<< ERROR OCCURS HERE
} catch (IOException e ) {
}

Graphics2D gfx= image.createGraphics();
gfx.setFont(new Font("Helvetica", Font.PLAIN, 10));
gfx.setColor(new Color(255,255,255));

int offset= // some integer
gfx.drawString("Test",offset,48);

try {
ImageIO.write(image, "png", iconFile);
} catch (IOException e ) {
}

Here's the error occuring in the ImageIO package

Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: LUT has improper length!
at javax.imageio.ImageTypeSpecifier$Indexed.<init>(Unknown Source)
at javax.imageio.ImageTypeSpecifier.createIndexed(Unknown Source)
at com.sun.imageio.plugins.png.PNGImageReader.getImageTypes(Unknown Source)
at com.sun.imageio.plugins.png.PNGImageReader.readImage(Unknown Source)
at com.sun.imageio.plugins.png.PNGImageReader.read(Unknown Source)
at javax.imageio.ImageIO.read(Unknown Source)
at javax.imageio.ImageIO.read(Unknown Source)

The original PNG file was created by PaintShopPro.
Mozilla Firefox and Internet Exploder have no problems displaying it.

Any suggestions on how to read and write small graphic files (60x60 images)
would be greatly appreciated.

--
Robert Metzger
Hewlett-Packard Company
High Performance Computing Division

Andrey Kuznetsov

unread,
Jan 13, 2005, 7:01:36 PM1/13/05
to
Robert,

>I am unable to get PNG reading to work using the javax.imageio.ImageIO
>package.
> I'm using PNG because ImageIO doesn't have a GIF writer
> (I need to both read and write) and the JPEG writer blurs
> my pictures in very ugly ways.

you can find many libraries to read and write images here:
http://www.geocities.com/marcoschmidt.geo/java-image-coding.html


You can also try Imagero Reader: http://reader.imagero.com

Note: next version of Imagero Reader will include possibility to manipulate
JPEG images without quality loss.

> Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException:
> LUT has improper length!
> at javax.imageio.ImageTypeSpecifier$Indexed.<init>(Unknown Source)
> at javax.imageio.ImageTypeSpecifier.createIndexed(Unknown Source)
> at com.sun.imageio.plugins.png.PNGImageReader.getImageTypes(Unknown
> Source)
> at com.sun.imageio.plugins.png.PNGImageReader.readImage(Unknown
> Source)
> at com.sun.imageio.plugins.png.PNGImageReader.read(Unknown Source)
> at javax.imageio.ImageIO.read(Unknown Source)
> at javax.imageio.ImageIO.read(Unknown Source)

if you send me sample image I can try to investigate this problem.
my email can be found here: http://reader.imagero.com/mailto.php

Regards

Andrei

--
Andrey Kuznetsov
http://uio.dev.java.net Unified I/O for Java
http://reader.imagero.com Java image reader
http://jgui.imagero.com Java GUI components and utilities


0 new messages