R
Robert Metzger
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.
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.