public PNGDecoder(InputStream input) throws IOException {
                this.input = input;
                this.crc = new CRC32();
                this.buffer = new byte[4096];
                
                readFully(buffer, 0, SIGNATURE.length);
                if(!checkSignature(buffer)) {
                        throw new IOException("Not a valid PNG file");
                }
                
                openChunk(IHDR);
                readIHDR();
                closeChunk();
                
                searchIDAT: for(;;) {
                        openChunk();
                        switch(chunkType) {
                                case IDAT:
                                        break searchIDAT;
                                case PLTE:
                                        readPLTE();
                                        break;
                                case tRNS:
                                        readtRNS();
                                        break;
                        }
                        closeChunk();
                }
                
                if(colorType == COLOR_INDEXED && palette == null) {
                        throw new IOException("Missing PLTE chunk");
                }
        }