Skip to main content

ImageIO with eclipse

2 replies [Last post]
justin_warren
Offline
Joined: 2006-10-23
Points: 0

Anyone else having problems with this? When I install the JDK version, everything works fine. (ie. I can use the CLibPNGReader/Writer).

When i try to install the classpath version, then import the jars into my project classpath, I get the regular PNGImageReader (which doesn't support compression, which is what I need).

Is it just something with my setup?

thanks
Justin

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
davince
Offline
Joined: 2005-01-07
Points: 0

Did you also include the jai-codecs.jar in your class path? Have you iterated over all installed plugins to see whether the correct png version is there? Maybe you should invoke ImageIO.scanForPlugins() before attempting to load a PNG?

justin_warren
Offline
Joined: 2006-10-23
Points: 0

this is my code..
I scan for new plugins, and the second invocation of writers.next() returns a null.. the same code with the JDK install returns the CLibPNGWriter..

I import all the jars. What i think is happening is that it cant find the .dll files required. Not sure how to make eclipse look for those. Perhaps I should post a similar question on an eclipse forum..

private ImageWriter getImageWriter(String mimeType) throws IllegalArgumentException
{

ImageWriter writer = null;
String[] contentType = mimeType.split(";");
String format = contentType[0];

if (isWriterAvailable(format))
{
ImageIO.scanForPlugins();
Iterator writers = ImageIO.getImageWritersByMIMEType(format);
writer = (ImageWriter) writers.next();
//writers.next();
}
else
{
throw new IllegalArgumentException("No writer for mimeType '" + format + "' is available");
}
return writer;
}