X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fxwt%2Ftranslators%2FPNG.java;fp=src%2Forg%2Fxwt%2Ftranslators%2FPNG.java;h=19e382fd5b2a19cee9673446af48e820ec892ce0;hb=42da60bd167403eccc3466575772819007388cfd;hp=9e6b8d54a53a85e3f84a5f0244ddc044b265e7bb;hpb=a81a151e639664cb340cf3726f9e8b9c77d125fb;p=org.ibex.core.git diff --git a/src/org/xwt/translators/PNG.java b/src/org/xwt/translators/PNG.java index 9e6b8d5..19e382f 100644 --- a/src/org/xwt/translators/PNG.java +++ b/src/org/xwt/translators/PNG.java @@ -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 ///////////////////////////////////////////////////////////////////////