Java Code Examples for javax.imageio.plugins.tiff.TIFFTag#TIFF_LONG
The following examples show how to use
javax.imageio.plugins.tiff.TIFFTag#TIFF_LONG .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TIFFT4Compressor.java From Bytecoder with Apache License 2.0 | 6 votes |
/** * Sets the value of the {@code metadata} field. * * <p> The implementation in this class also sets local options * from the T4_OPTIONS field if it exists, and if it doesn't, adds * it with default values.</p> * * @param metadata the {@code IIOMetadata} object for the * image being written. * * @see #getMetadata() */ public void setMetadata(IIOMetadata metadata) { super.setMetadata(metadata); if (metadata instanceof TIFFImageMetadata) { TIFFImageMetadata tim = (TIFFImageMetadata)metadata; TIFFField f = tim.getTIFFField(BaselineTIFFTagSet.TAG_T4_OPTIONS); if (f != null) { int options = f.getAsInt(0); is1DMode = (options & 0x1) == 0; isEOLAligned = (options & 0x4) == 0x4; } else { long[] oarray = new long[1]; oarray[0] = (isEOLAligned ? 0x4 : 0x0) | (is1DMode ? 0x0 : 0x1); BaselineTIFFTagSet base = BaselineTIFFTagSet.getInstance(); TIFFField T4Options = new TIFFField(base.getTag(BaselineTIFFTagSet.TAG_T4_OPTIONS), TIFFTag.TIFF_LONG, 1, oarray); tim.rootIFD.addTIFFField(T4Options); } } }
Example 2
Source File: TIFFT4Compressor.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * Sets the value of the {@code metadata} field. * * <p> The implementation in this class also sets local options * from the T4_OPTIONS field if it exists, and if it doesn't, adds * it with default values.</p> * * @param metadata the {@code IIOMetadata} object for the * image being written. * * @see #getMetadata() */ public void setMetadata(IIOMetadata metadata) { super.setMetadata(metadata); if (metadata instanceof TIFFImageMetadata) { TIFFImageMetadata tim = (TIFFImageMetadata)metadata; TIFFField f = tim.getTIFFField(BaselineTIFFTagSet.TAG_T4_OPTIONS); if (f != null) { int options = f.getAsInt(0); is1DMode = (options & 0x1) == 0; isEOLAligned = (options & 0x4) == 0x4; } else { long[] oarray = new long[1]; oarray[0] = (isEOLAligned ? 0x4 : 0x0) | (is1DMode ? 0x0 : 0x1); BaselineTIFFTagSet base = BaselineTIFFTagSet.getInstance(); TIFFField T4Options = new TIFFField(base.getTag(BaselineTIFFTagSet.TAG_T4_OPTIONS), TIFFTag.TIFF_LONG, 1, oarray); tim.rootIFD.addTIFFField(T4Options); } } }
Example 3
Source File: TIFFT6Compressor.java From Bytecoder with Apache License 2.0 | 5 votes |
public int encode(byte[] b, int off, int width, int height, int[] bitsPerSample, int scanlineStride) throws IOException { if (bitsPerSample.length != 1 || bitsPerSample[0] != 1) { throw new IIOException( "Bits per sample must be 1 for T6 compression!"); } if (metadata instanceof TIFFImageMetadata) { TIFFImageMetadata tim = (TIFFImageMetadata)metadata; long[] options = new long[1]; options[0] = 0; BaselineTIFFTagSet base = BaselineTIFFTagSet.getInstance(); TIFFField T6Options = new TIFFField(base.getTag(BaselineTIFFTagSet.TAG_T6_OPTIONS), TIFFTag.TIFF_LONG, 1, options); tim.rootIFD.addTIFFField(T6Options); } // See comment in TIFFT4Compressor int maxBits = 9*((width + 1)/2) + 2; int bufSize = (maxBits + 7)/8; bufSize = height*(bufSize + 2) + 12; byte[] compData = new byte[bufSize]; int bytes = encodeT6(b, scanlineStride, 8*off, width, height, compData); stream.write(compData, 0, bytes); return bytes; }
Example 4
Source File: TIFFT6Compressor.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public int encode(byte[] b, int off, int width, int height, int[] bitsPerSample, int scanlineStride) throws IOException { if (bitsPerSample.length != 1 || bitsPerSample[0] != 1) { throw new IIOException( "Bits per sample must be 1 for T6 compression!"); } if (metadata instanceof TIFFImageMetadata) { TIFFImageMetadata tim = (TIFFImageMetadata)metadata; long[] options = new long[1]; options[0] = 0; BaselineTIFFTagSet base = BaselineTIFFTagSet.getInstance(); TIFFField T6Options = new TIFFField(base.getTag(BaselineTIFFTagSet.TAG_T6_OPTIONS), TIFFTag.TIFF_LONG, 1, options); tim.rootIFD.addTIFFField(T6Options); } // See comment in TIFFT4Compressor int maxBits = 9*((width + 1)/2) + 2; int bufSize = (maxBits + 7)/8; bufSize = height*(bufSize + 2) + 12; byte[] compData = new byte[bufSize]; int bytes = encodeT6(b, scanlineStride, 8*off, width, height, compData); stream.write(compData, 0, bytes); return bytes; }
Example 5
Source File: TIFFIFD.java From Bytecoder with Apache License 2.0 | 4 votes |
private static void writeTIFFFieldToStream(TIFFField field, ImageOutputStream stream) throws IOException { int count = field.getCount(); Object data = field.getData(); switch (field.getType()) { case TIFFTag.TIFF_ASCII: for (int i = 0; i < count; i++) { String s = ((String[])data)[i]; int length = s.length(); for (int j = 0; j < length; j++) { stream.writeByte(s.charAt(j) & 0xff); } stream.writeByte(0); } break; case TIFFTag.TIFF_UNDEFINED: case TIFFTag.TIFF_BYTE: case TIFFTag.TIFF_SBYTE: stream.write((byte[])data); break; case TIFFTag.TIFF_SHORT: stream.writeChars((char[])data, 0, ((char[])data).length); break; case TIFFTag.TIFF_SSHORT: stream.writeShorts((short[])data, 0, ((short[])data).length); break; case TIFFTag.TIFF_SLONG: stream.writeInts((int[])data, 0, ((int[])data).length); break; case TIFFTag.TIFF_LONG: for (int i = 0; i < count; i++) { stream.writeInt((int)(((long[])data)[i])); } break; case TIFFTag.TIFF_IFD_POINTER: stream.writeInt(0); // will need to be backpatched break; case TIFFTag.TIFF_FLOAT: stream.writeFloats((float[])data, 0, ((float[])data).length); break; case TIFFTag.TIFF_DOUBLE: stream.writeDoubles((double[])data, 0, ((double[])data).length); break; case TIFFTag.TIFF_SRATIONAL: for (int i = 0; i < count; i++) { stream.writeInt(((int[][])data)[i][0]); stream.writeInt(((int[][])data)[i][1]); } break; case TIFFTag.TIFF_RATIONAL: for (int i = 0; i < count; i++) { long num = ((long[][])data)[i][0]; long den = ((long[][])data)[i][1]; stream.writeInt((int)num); stream.writeInt((int)den); } break; default: // error } }
Example 6
Source File: TIFFFieldNode.java From Bytecoder with Apache License 2.0 | 4 votes |
private static boolean isIFD(TIFFField f) { int type = f.getType(); return f.hasDirectory() && (type == TIFFTag.TIFF_LONG || type == TIFFTag.TIFF_IFD_POINTER); }
Example 7
Source File: TIFFIFD.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
private static void writeTIFFFieldToStream(TIFFField field, ImageOutputStream stream) throws IOException { int count = field.getCount(); Object data = field.getData(); switch (field.getType()) { case TIFFTag.TIFF_ASCII: for (int i = 0; i < count; i++) { String s = ((String[])data)[i]; int length = s.length(); for (int j = 0; j < length; j++) { stream.writeByte(s.charAt(j) & 0xff); } stream.writeByte(0); } break; case TIFFTag.TIFF_UNDEFINED: case TIFFTag.TIFF_BYTE: case TIFFTag.TIFF_SBYTE: stream.write((byte[])data); break; case TIFFTag.TIFF_SHORT: stream.writeChars((char[])data, 0, ((char[])data).length); break; case TIFFTag.TIFF_SSHORT: stream.writeShorts((short[])data, 0, ((short[])data).length); break; case TIFFTag.TIFF_SLONG: stream.writeInts((int[])data, 0, ((int[])data).length); break; case TIFFTag.TIFF_LONG: for (int i = 0; i < count; i++) { stream.writeInt((int)(((long[])data)[i])); } break; case TIFFTag.TIFF_IFD_POINTER: stream.writeInt(0); // will need to be backpatched break; case TIFFTag.TIFF_FLOAT: stream.writeFloats((float[])data, 0, ((float[])data).length); break; case TIFFTag.TIFF_DOUBLE: stream.writeDoubles((double[])data, 0, ((double[])data).length); break; case TIFFTag.TIFF_SRATIONAL: for (int i = 0; i < count; i++) { stream.writeInt(((int[][])data)[i][0]); stream.writeInt(((int[][])data)[i][1]); } break; case TIFFTag.TIFF_RATIONAL: for (int i = 0; i < count; i++) { long num = ((long[][])data)[i][0]; long den = ((long[][])data)[i][1]; stream.writeInt((int)num); stream.writeInt((int)den); } break; default: // error } }
Example 8
Source File: TIFFFieldNode.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
private static boolean isIFD(TIFFField f) { int type = f.getType(); return f.hasDirectory() && (type == TIFFTag.TIFF_LONG || type == TIFFTag.TIFF_IFD_POINTER); }