Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > javax.imageio package dies reading PNG file

Reply
Thread Tools

javax.imageio package dies reading PNG file

 
 
Robert Metzger
Guest
Posts: n/a
 
      01-13-2005
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,4;

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>(Un known Source)
at javax.imageio.ImageTypeSpecifier.createIndexed(Unk nown Source)
at com.sun.imageio.plugins.png.PNGImageReader.getImag eTypes(Unknown Source)
at com.sun.imageio.plugins.png.PNGImageReader.readIma ge(Unknown Source)
at com.sun.imageio.plugins.png.PNGImageReader.read(Un known 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
 
Reply With Quote
 
 
 
 
Andrey Kuznetsov
Guest
Posts: n/a
 
      01-14-2005
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/marcoschmid...ge-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>(Un known Source)
> at javax.imageio.ImageTypeSpecifier.createIndexed(Unk nown Source)
> at com.sun.imageio.plugins.png.PNGImageReader.getImag eTypes(Unknown
> Source)
> at com.sun.imageio.plugins.png.PNGImageReader.readIma ge(Unknown
> Source)
> at com.sun.imageio.plugins.png.PNGImageReader.read(Un known 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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
python make dies :libtk8.5.so: cannot open shared object file: Nosuch file or directory Tony Lay Python 1 07-13-2009 02:24 PM
Package HTML - Missing package documentation file jochenhebbrecht@gmail.com Java 1 11-27-2007 01:59 PM
ANN: PNG image CAPTCHA with PNG canvas available (SkimpyGimpy) aaronwmail-usenet@yahoo.com Python 0 04-18-2007 07:33 PM
ImageIO have problem of reading PNG? carfield@gmail.com Java 2 02-20-2005 05:22 PM
Perl 'system' Creates Program That Dies When First C Program Dies Christopher M. Lusardi Perl Misc 3 10-19-2003 11:53 AM



Advertisments