2003/04/10 01:41:43
[org.ibex.core.git] / src / org / xwt / plat / GCJ.java
index 34c89ea..4a6d23f 100644 (file)
@@ -2,6 +2,8 @@
 package org.xwt.plat;
 
 import org.xwt.*;
+import org.xwt.util.*;
+import java.io.*;
 
 /** common superclass for all platforms that use GCJ to compile a native binary */
 public abstract class GCJ extends Platform {
@@ -20,5 +22,30 @@ public abstract class GCJ extends Platform {
         public Java2Weak(Object o) { super(o); }
     }
         
+    // FIXME
+    protected ImageDecoder _decodeJPEG(InputStream is, String name) {
+       try {
+           return new JPEG(is);
+       } catch (Exception e) {
+           Log.log(this, "Exception while decoding JPEG image " + name);
+           Log.log(this, e);
+           return null;
+       }
+    }
+
+    /** Converts an InputStream carrying a JPEG image into an ARGB int[] */
+    private static class JPEG implements ImageDecoder {
+       int[] data;
+       byte[] buffer;
+       int width, height;
+       InputStream is;
+       
+       public final int[] getData() { return data; }
+       public final int getWidth() { return width; }
+       public final int getHeight() { return height; }
+       private JPEG(InputStream is) { this.is = is; nativeDecompress(); buffer = null; }
+       private native void nativeDecompress();
+    }
+
 }