void decodeIdat() { int nbitDepth = bitDepth; if (nbitDepth == 16) nbitDepth = 8; int size = -1; bytesPerPixel = (bitDepth == 16) ? 2 : 1; switch (colorType) { case 0: size = (nbitDepth * width + 7) / 8 * height; break; case 2: size = width * 3 * height; bytesPerPixel *= 3; break; case 3: if (interlaceMethod == 1) size = (nbitDepth * width + 7) / 8 * height; bytesPerPixel = 1; break; case 4: size = width * height; bytesPerPixel *= 2; break; case 6: size = width * 3 * height; bytesPerPixel *= 4; break; } if (size >= 0) image = new byte[size]; if (palShades) smask = new byte[width * height]; else if (genBWMask) smask = new byte[(width + 7) / 8 * height]; ByteArrayInputStream bai = new ByteArrayInputStream(idat.getBuf(), 0, idat.size()); InputStream infStream = new InflaterInputStream(bai, new Inflater()); dataStream = new DataInputStream(infStream); if (interlaceMethod != 1) { decodePass(0, 0, 1, 1, width, height); } else { decodePass(0, 0, 8, 8, (width + 7) / 8, (height + 7) / 8); decodePass(4, 0, 8, 8, (width + 3) / 8, (height + 7) / 8); decodePass(0, 4, 4, 8, (width + 3) / 4, (height + 3) / 8); decodePass(2, 0, 4, 4, (width + 1) / 4, (height + 3) / 4); decodePass(0, 2, 2, 4, (width + 1) / 2, (height + 1) / 4); decodePass(1, 0, 2, 2, width / 2, (height + 1) / 2); decodePass(0, 1, 1, 2, width, height / 2); } }