javax.imageio.plugins.tiff.BaselineTIFFTagSet#getTag ( )源码实例Demo

下面列出了javax.imageio.plugins.tiff.BaselineTIFFTagSet#getTag ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Bytecoder   文件: TIFFT4Compressor.java
/**
 * 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);
        }
    }
}
 
源代码2 项目: openjdk-jdk9   文件: TIFFT4Compressor.java
/**
 * 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);
        }
    }
}
 
源代码3 项目: Bytecoder   文件: TIFFT6Compressor.java
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;
}
 
源代码4 项目: openjdk-jdk9   文件: TIFFT6Compressor.java
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;
}