fix class loader issues with JAI ImageIO

This commit is contained in:
Ben Fry
2013-10-08 20:33:13 -04:00
parent 0898ce1a45
commit 44505258b9
3 changed files with 29 additions and 4 deletions
+2 -2
View File
@@ -53,8 +53,8 @@ public class Base {
// static private boolean RELEASE = false;
/** True if heavy debugging error/log messages are enabled */
static public boolean DEBUG = false;
// static public boolean DEBUG = true;
// static public boolean DEBUG = false;
static public boolean DEBUG = true;
static HashMap<Integer, String> platformNames =
new HashMap<Integer, String>();
@@ -32,6 +32,7 @@ import java.io.FileFilter;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.prefs.Preferences;
@@ -619,16 +620,37 @@ public class MovieMaker extends JFrame implements Tool {
private BufferedImage readImage(File file) throws IOException {
/*
BufferedImage image = null;
try {
Class<?> iio = getClass().getClassLoader().loadClass("javax.imageio.ImageIO");
Method readMethod = iio.getMethod("read", new Class[] { File.class });
image = (BufferedImage) readMethod.invoke(null, file);
Method scanMethod = iio.getMethod("scanForPlugins", new Class[] { });
scanMethod.invoke(null);
Method formatMethod = iio.getMethod("getReaderFormatNames", new Class[] { });
String[] formats = (String[]) formatMethod.invoke(null);
for (String f : formats) {
System.out.println("dynamically found " + f);
}
} catch (Exception e) {
throw new RuntimeException(e);
}
*/
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
// System.out.println("reading image with CL " + getClass().getClassLoader());
BufferedImage image = ImageIO.read(file);
/*
String[] loadImageFormats = ImageIO.getReaderFormatNames();
if (loadImageFormats != null) {
for (String format : loadImageFormats) {
System.out.println(format);
}
}
*/
if (image == null) {
String path = file.getAbsolutePath();
+3
View File
@@ -16,6 +16,9 @@ X https://github.com/processing/processing/issues/2103
X still having right-click issues (re-opened)
X https://github.com/processing/processing/issues/2103
X add gamma, better image options, etc to MovieMaker
_ fix file selection dialog (just import PApplet) with MovieMaker
X add appbundler.jar, otherwise folks have to include Xcode
_ if they want to build appbundler, they'll need Xcode
_ and the command line tools Preferences > Downloads > Command Line Tools