2003/09/23 08:25:00
[org.ibex.core.git] / src / org / xwt / translators / PNG.java
index 9e6b8d5..19e382f 100644 (file)
@@ -22,32 +22,16 @@ import java.util.Enumeration;
 import java.util.zip.*;
 
 /** Converts an InputStream carrying a PNG image into an ARGB int[] */
-public class PNG extends ImageDecoder {
+public class PNG {
 
+    public PNG() { }
+    
     // Public Methods ///////////////////////////////////////////////////////////////////////////////
 
-    /** returns the ARGB int[] representing the last image processed */
-    public final int[] getData() { return data; }
-
-    /** returns the width of the last image processed */
-    public final int getWidth() { return width; }
-
-    /** returns the height of the last image processed */
-    public final int getHeight() { return height; }
-
     /** process a PNG as an inputstream; returns null if there is an error
         @param name A string describing the image, to be used when logging errors
     */
-    public static PNG decode(InputStream is, String name) {
-        try {
-            return new PNG(is, name);
-        } catch (Exception e) {
-            if (Log.on) Log.log(PNG.class, e);
-            return null;
-        }
-    }
-
-    private PNG(InputStream is, String name) throws IOException {
+    public Picture fromInputStream(InputStream is, String name) throws IOException {
         underlyingStream = is;
         target_offset = 0;
         inputStream = new DataInputStream(underlyingStream);
@@ -58,7 +42,7 @@ public class PNG extends ImageDecoder {
             Log.log(this, "PNG: error: input file " + name + " is not a PNG file");
             data = new int[] { };
             width = height = 0;
-            return;
+            return null;
         }
         
         DONE: while (!error) {
@@ -95,6 +79,8 @@ public class PNG extends ImageDecoder {
             int crc = inputStream.readInt();
             needChunkInfo = true;
         }
+
+        return Platform.createPicture(data, width, height);
     }
 
     // Chunk Handlers ///////////////////////////////////////////////////////////////////////