@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(); } }
private static boolean canDecode(ImageInputStream pInput) throws IOException { pInput.mark(); try { // Is it IFF if (pInput.readInt() == IFF.CHUNK_FORM) { pInput.readInt();// Skip length field int type = pInput.readInt(); // Is it ILBM or PBM if (type == IFF.TYPE_ILBM || type == IFF.TYPE_PBM) { return true; } } } finally { pInput.reset(); } return false; }
private void readColorMap(final BitmapIndexed pBitmap) throws IOException { int colorCount = pBitmap.getColorCount(); for (int i = 0; i < colorCount; i++) { // aRGB (a is "Reserved") pBitmap.colors[i] = (imageInput.readInt() & 0xffffff) | 0xff000000; } }
@Override protected void readData(final ImageInputStream pInput) throws IOException { version = pInput.readInt(); aspect = pInput.readDouble(); } }
@Override protected void readData(final ImageInputStream pInput) throws IOException { format = pInput.readInt(); width = pInput.readInt(); height = pInput.readInt(); // This data isn't really useful, unless we're dealing with raw bytes widthBytes = pInput.readInt(); int totalSize = pInput.readInt(); // Hmm.. Is this really useful at all? // Consistency check int sizeCompressed = pInput.readInt(); if (sizeCompressed != (size - 28)) { throw new IIOException("Corrupt thumbnail in PSD document"); } // According to the spec, only 24 bits and 1 plane is supported int bits = pInput.readUnsignedShort(); int planes = pInput.readUnsignedShort(); if (bits != 24 && planes != 1) { // TODO: Warning/Exception } data = new byte[sizeCompressed]; pInput.readFully(data); }
public static DCXHeader read(final ImageInputStream imageInput) throws IOException { // typedef struct _DcxHeader // { // DWORD Id; /* DCX Id number */ // DWORD PageTable[1024]; /* Image offsets */ // } DCXHEAD; int magic = imageInput.readInt(); if (magic != DCX.MAGIC) { throw new IIOException(String.format("Not a DCX file. Expected DCX magic %02x, read %02x", DCX.MAGIC, magic)); } int[] offsets = new int[1024]; int count = 0; do { offsets[count] = imageInput.readInt(); } while (offsets[count] != 0 && count++ < offsets.length); return new DCXHeader(count == offsets.length ? offsets : Arrays.copyOf(offsets, count)); }
@Override protected void readData(final ImageInputStream pInput) throws IOException { /* 4 bytes version 1 byte hasRealMergedData Unicode string: writer name Unicode string: reader name 4 bytes file version. */ version = pInput.readInt(); hasRealMergedData = pInput.readBoolean(); writer = PSDUtil.readUnicodeString(pInput); reader = PSDUtil.readUnicodeString(pInput); fileVersion = pInput.readInt(); }
private static boolean canDecode(ImageInputStream input) throws IOException { try { input.mark(); return input.readInt() == ICNS.MAGIC; } finally { input.reset(); } }
private static int readMagic(final ImageInputStream stream) throws IOException { stream.mark(); try { return stream.readInt(); } 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 }
PSDColorData(final ImageInputStream pInput) throws IOException { int length = pInput.readInt(); if (length == 0) { throw new IIOException("No palette information in PSD"); } else if (length % 3 != 0) { throw new IIOException("Wrong palette information in PSD"); } // NOTE: Spec says length may only be 768 bytes (256 RGB triplets) colors = new byte[length]; pInput.readFully(colors); // NOTE: Could be a padding byte here, if not even.. }
@Override protected void readData(ImageInputStream pInput) throws IOException { if (size != 16) { throw new IIOException("Resolution info length expected to be 16: " + size); } hRes = PSDUtil.fixedPointToFloat(pInput.readInt()); hResUnit = pInput.readShort(); widthUnit = pInput.readShort(); vRes = PSDUtil.fixedPointToFloat(pInput.readInt()); vResUnit = pInput.readShort(); heightUnit = pInput.readShort(); }
public boolean canDecodeInput(final Object pSource) throws IOException { if (!(pSource instanceof ImageInputStream)) { return false; } ImageInputStream stream = (ImageInputStream) pSource; stream.mark(); try { if (stream.readInt() == PSD.SIGNATURE_8BPS) { int version = stream.readUnsignedShort(); switch (version) { case PSD.VERSION_PSD: case PSD.VERSION_PSB: break; default: return false; } return true; } return false; } finally { stream.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 PNM.PBM_PLAIN: case PNM.PBM: case PNM.PGM_PLAIN: case PNM.PGM: case PNM.PPM_PLAIN: case PNM.PPM: case PNM.PFM_GRAY: case PNM.PFM_RGB: return true; case PNM.PAM: return stream.readInt() != PNM.XV_THUMBNAIL_MAGIC; default: return false; } } finally { stream.reset(); } }
@Override public Directory read(final ImageInputStream input) throws IOException { Validate.notNull(input, "input"); List<PSDEntry> entries = new ArrayList<>(); while (true) { try { int type = input.readInt(); switch (type) { case PSD.RESOURCE_TYPE_IMAGEREADY: case PSD.RESOURCE_TYPE_PHOTODELUXE: case PSD.RESOURCE_TYPE_LIGHTROOM: case PSD.RESOURCE_TYPE_DCSR: // TODO: Warning for these types! case PSD.RESOURCE_TYPE: break; default: throw new IIOException(String.format("Wrong image resource type, expected '8BIM': '%08x'", type)); } short id = input.readShort(); PSDResource resource = new PSDResource(id, input); entries.add(new PSDEntry(id, resource.name(), resource.data())); } catch (EOFException e) { break; } } return new PSDDirectory(entries); }
private boolean isPICT(final ImageInputStream pStream) throws IOException { // TODO: Need to validate better... // Size may be 0, so we can't use this for validation... pStream.readUnsignedShort(); // Sanity check bounding box int y1 = pStream.readUnsignedShort(); int x1 = pStream.readUnsignedShort(); // TODO: Figure out if frame can ever start at negative bounds... // if (x1 != 0 || y1 != 0) { // return false; // } int y2 = pStream.readUnsignedShort(); int x2 = pStream.readUnsignedShort(); if (x2 - x1 < 0 || y2 - y1 < 0) { return false; } int magic = pStream.readInt(); return (magic & 0xffff0000) == PICT.MAGIC_V1 || magic == PICT.MAGIC_V2; }
@Override public boolean canDecodeInput(final Object source) throws IOException { if (!(source instanceof ImageInputStream)) { return false; } ImageInputStream stream = (ImageInputStream) source; stream.mark(); try { ByteOrder originalByteOrder = stream.getByteOrder(); stream.setByteOrder(ByteOrder.LITTLE_ENDIAN); try { return stream.readInt() == DCX.MAGIC; } finally { stream.setByteOrder(originalByteOrder); } } finally { stream.reset(); } }