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);
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) {
int crc = inputStream.readInt();
needChunkInfo = true;
}
+
+ return Platform.createPicture(data, width, height);
}
// Chunk Handlers ///////////////////////////////////////////////////////////////////////