@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); }
@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 static PNMHeader parse(ImageInputStream input) throws IOException { short type = input.readShort(); return createParser(input, type).parse(); }
@Override protected void readData(final ImageInputStream pInput) throws IOException { style = pInput.readShort(); xLocation = pInput.readFloat(); ylocation = pInput.readFloat(); scale = pInput.readFloat(); } }
@Override public Directory read(final ImageInputStream input) throws IOException { Validate.notNull(input, "input"); Map<Short, Entry> entries = new LinkedHashMap<>(); // 0x1c identifies start of a tag while (input.read() == 0x1c) { short tagId = input.readShort(); int tagByteCount = input.readUnsignedShort(); boolean array = IPTC.Tags.isArray(tagId); Entry entry = readEntry(input, tagId, tagByteCount, array, array ? entries.get(tagId) : null); if (entry != null) { entries.put(tagId, entry); } } return new IPTCDirectory(entries.values()); }
@Override public IIOMetadata getImageMetadata(final int imageIndex) throws IOException { checkBounds(imageIndex); readImageResources(true); readLayerAndMaskInfo(true); // NOTE: Need to make sure compression is set in metadata, even without reading the image data! // TODO: Move this to readLayerAndMaskInfo? if (metadata.compression == -1) { imageInput.seek(metadata.imageDataStart); metadata.compression = imageInput.readShort(); } // Initialize XMP data etc. for (PSDImageResource resource : metadata.imageResources) { if (resource instanceof PSDDirectoryResource) { PSDDirectoryResource directoryResource = (PSDDirectoryResource) resource; try { directoryResource.initDirectory(); } catch (IOException e) { processWarningOccurred(String.format("Error parsing %s: %s", resource.getClass().getSimpleName(), e.getMessage())); } } } return metadata; // TODO: clone if we change to mutable metadata }
@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(); } }
int version = pStream.readShort(); if (DEBUG) { System.out.println(String.format("PICT version: 0x%04x", version)); this.version = 1; else if (version == PICT.OP_VERSION && pStream.readShort() == PICT.OP_VERSION_2) { this.version = 2; if (pStream.readShort() != PICT.OP_HEADER_OP) { throw new IIOException("Error in PICT header: Invalid HeaderOp, expected 0x0c00"); short y2 = pStream.readShort(); short x2 = pStream.readShort(); short h2 = pStream.readShort(); short w2 = pStream.readShort();
@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(); } }
@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 TIFFEntry readEntry(final ImageInputStream pInput) throws IOException { int tagId = pInput.readUnsignedShort(); short type = pInput.readShort(); int count = readValueCount(pInput); // Number of values
int layerCount = imageInput.readShort(); metadata.layerCount = layerCount;
// CHAR Dummy2[404]; /* Not used */ short magic = imageInput.readShort(); if (magic != SGI.MAGIC) { throw new IIOException(String.format("Not an SGI image. Expected SGI magic %04x, read %04x", SGI.MAGIC, magic));
int compression = imageInput.readShort(); metadata.compression = compression;
private void readBitmap16(final BitmapDescriptor pBitmap) throws IOException { // TODO: No idea if this actually works.. short[] pixels = new short[pBitmap.getWidth() * pBitmap.getHeight()]; // TODO: Support TYPE_USHORT_565 and the RGB 444/ARGB 4444 layouts // Will create TYPE_USHORT_555 DirectColorModel cm = new DirectColorModel(16, 0x7C00, 0x03E0, 0x001F); DataBuffer buffer = new DataBufferShort(pixels, pixels.length); WritableRaster raster = Raster.createPackedRaster( buffer, pBitmap.getWidth(), pBitmap.getHeight(), pBitmap.getWidth(), cm.getMasks(), null ); pBitmap.image = new BufferedImage(cm, raster, cm.isAlphaPremultiplied(), null); for (int y = 0; y < pBitmap.getHeight(); y++) { int offset = (pBitmap.getHeight() - y - 1) * pBitmap.getWidth(); imageInput.readFully(pixels, offset, pBitmap.getWidth()); // Skip to 32 bit boundary if (pBitmap.getWidth() % 2 != 0) { imageInput.readShort(); } if (abortRequested()) { processReadAborted(); break; } processImageProgress(100 * y / (float) pBitmap.getHeight()); } // TODO: Might be mask!? }
short id = pInput.readShort();
short channelId = pInput.readShort(); long length = largeFormat ? pInput.readLong() : pInput.readUnsignedInt();
pInput.readShort(); // Pad dataLeft -= 2;