Java Code Examples for javax.imageio.plugins.tiff.BaselineTIFFTagSet#getTag()
The following examples show how to use
javax.imageio.plugins.tiff.BaselineTIFFTagSet#getTag() .
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; }