static boolean canDecode(final ImageInputStream pInput, final int pType) throws IOException { byte[] signature = new byte[4]; try { pInput.mark(); pInput.readFully(signature); int count = pInput.readByte() + (pInput.readByte() << 8); return (signature[0] == 0x0 && signature[1] == 0x0 && signature[2] == pType && signature[3] == 0x0 && count > 0); } finally { pInput.reset(); } }
@Override public boolean canDecodeInput(final Object source) throws IOException { if (!(source instanceof ImageInputStream)) { return false; } ImageInputStream stream = (ImageInputStream) source; stream.mark(); try { short magic = stream.readShort(); switch (magic) { case SGI.MAGIC: byte compression = stream.readByte(); byte bpp = stream.readByte(); return (compression == SGI.COMPRESSION_NONE || compression == SGI.COMPRESSION_RLE) && (bpp == 1 || bpp == 2); default: return false; } } finally { stream.reset(); } }
public PSDLayerBlendMode(final ImageInputStream pInput) throws IOException { int blendModeSig = pInput.readInt(); if (blendModeSig != PSD.RESOURCE_TYPE) { throw new IIOException("Illegal PSD Blend Mode signature, expected 8BIM: " + PSDUtil.intToStr(blendModeSig)); } blendMode = pInput.readInt(); opacity = pInput.readUnsignedByte(); clipping = pInput.readUnsignedByte(); flags = pInput.readByte(); pInput.readByte(); // Pad }
thetmp[0] = imageNullFileIS.readByte(); BitSet tmp = fromByteArray(thetmp);
@Override protected void readData(ImageInputStream pInput) throws IOException { if (size % 14 != 0) { throw new IIOException("Display info length expected to be mod 14: " + size); } // long left = size; // while (left > 0) { colorSpace = pInput.readShort(); // Color[4]...? colors = new short[4]; colors[0] = pInput.readShort(); colors[1] = pInput.readShort(); colors[2] = pInput.readShort(); colors[3] = pInput.readShort(); opacity = pInput.readShort(); kind = pInput.readByte(); pInput.readByte(); // Pad // left -= 14; // } pInput.skipBytes(size - 14); }
pInput.readByte();
@Override protected void readData(final ImageInputStream pInput) throws IOException { version = pInput.readInt(); gridCycleVertical = pInput.readInt(); gridCycleHorizontal = pInput.readInt(); guideCount = pInput.readInt(); guides = new GuideResource[guideCount]; for (int i = 0; i < guides.length; i++) { guides[i] = new GuideResource(); guides[i].location = pInput.readInt(); guides[i].direction = pInput.readByte(); } }
byte quote = stream.readByte();
PSDImageResource(final short resourceId, final ImageInputStream input) throws IOException { id = resourceId; name = PSDUtil.readPascalString(input); // Skip pad int nameSize = name.length() + 1; if (nameSize % 2 != 0) { input.readByte(); } size = input.readUnsignedInt(); long startPos = input.getStreamPosition(); readData(new SubImageInputStream(input, size)); // NOTE: This should never happen, however it's safer to keep it here to if (input.getStreamPosition() != startPos + size) { input.seek(startPos + size); } // Data is even-padded (word aligned) if (size % 2 != 0) { input.read(); } }
PSDResource(final short resourceId, final ImageInputStream input) throws IOException { id = resourceId; name = readPascalString(input); // Skip pad int nameSize = name.length() + 1; if (nameSize % 2 != 0) { input.readByte(); } size = input.readUnsignedInt(); long startPos = input.getStreamPosition(); readData(new SubImageInputStream(input, size)); // NOTE: This should never happen, however it's safer to keep it here for future compatibility if (input.getStreamPosition() != startPos + size) { input.seek(startPos + size); } // Data is even-padded (word aligned) if (size % 2 != 0) { input.read(); } }
int softwareLetter = stream.readByte();
private IndexColorModel getVGAPalette() throws IOException { if (!readPalette) { readHeader(); // Mark palette as read, to avoid further attempts readPalette = true; if (header.getVersion() >= PCX.VERSION_3 || header.getVersion() == PCX.VERSION_2_8_PALETTE) { // We can't simply skip to an offset, as the RLE compression makes the file size unpredictable skipToEOF(imageInput); int paletteSize = 256 * 3; // 256 * 3 for RGB // Seek backwards from EOF long paletteStart = imageInput.getStreamPosition() - paletteSize - 1; if (paletteStart > imageInput.getFlushedPosition()) { imageInput.seek(paletteStart); byte val = imageInput.readByte(); if (val == PCX.VGA_PALETTE_MAGIC) { byte[] palette = new byte[paletteSize]; imageInput.readFully(palette); vgaPalette = new IndexColorModel(8, 256, palette, 0, false); } } } } return vgaPalette; }
pStream.readByte(); origin = new Point(x, y); x = getXPtCoord(pStream.readByte()); y = getYPtCoord(pStream.readByte()); dh_dv = new Point(x, y); x = getXPtCoord(pStream.readByte()); y = getYPtCoord(pStream.readByte()); dh = getXPtCoord(pStream.readByte()); penPosition.translate(dh, 0); context.moveTo(penPosition); dv = getYPtCoord(pStream.readByte()); penPosition.translate(0, dv); context.moveTo(penPosition); y = getYPtCoord(pStream.readByte()); x = getXPtCoord(pStream.readByte()); penPosition.translate(x, y); context.moveTo(penPosition);
short expectedSOI = (short) (imageInput.readByte() << 8 | imageInput.readByte()); if (expectedSOI != (short) JPEG.SOI) { if (stripTileOffsets != null && stripTileOffsets.length == 1) { imageInput.seek(stripTileOffsets[0]); expectedSOI = (short) (imageInput.readByte() << 8 | imageInput.readByte()); if (expectedSOI == (short) JPEG.SOI) { realJPEGOffset = stripTileOffsets[0]; if ((short) (imageInput.readByte() << 8 | imageInput.readByte()) == (short) JPEG.SOS) { int len = 2 + (imageInput.readByte() << 8 | imageInput.readByte()); stripTileOffsets[0] += len; stripTileByteCounts[0] -= len; if ((short) (imageInput.readByte() << 8 | imageInput.readByte()) == (short) JPEG.SOS) { imageInput.seek(stripTileOffsets[i] + 14); // TODO: Read from SOS length from stream, in case of gray/CMYK length -= 14;
byte magic = imageInput.readByte(); if (magic != PCX.MAGIC) { throw new IIOException(String.format("Not a PCX image. Expected PCX magic 0x%02x: 0x%02x", PCX.MAGIC, magic));
return pInput.readByte();