下面列出了javax.imageio.plugins.tiff.BaselineTIFFTagSet#COMPRESSION_CCITT_RLE 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* Invokes the superclass method and then sets instance variables on
* the basis of the metadata set on this decompressor.
*/
public void beginDecoding() {
super.beginDecoding();
if(metadata instanceof TIFFImageMetadata) {
TIFFImageMetadata tmetadata = (TIFFImageMetadata)metadata;
TIFFField f;
f = tmetadata.getTIFFField(BaselineTIFFTagSet.TAG_FILL_ORDER);
this.fillOrder = f == null ?
BaselineTIFFTagSet.FILL_ORDER_LEFT_TO_RIGHT : f.getAsInt(0);
f = tmetadata.getTIFFField(BaselineTIFFTagSet.TAG_COMPRESSION);
this.compression = f == null ?
BaselineTIFFTagSet.COMPRESSION_CCITT_RLE : f.getAsInt(0);
f = tmetadata.getTIFFField(BaselineTIFFTagSet.TAG_T4_OPTIONS);
this.t4Options = f == null ? 0 : f.getAsInt(0);
this.oneD = (t4Options & 0x01);
// uncompressedMode - haven't dealt with this yet.
this.uncompressedMode = ((t4Options & 0x02) >> 1);
this.fillBits = ((t4Options & 0x04) >> 2);
f = tmetadata.getTIFFField(BaselineTIFFTagSet.TAG_T6_OPTIONS);
this.t6Options = f == null ? 0 : f.getAsInt(0);
} else {
this.fillOrder = BaselineTIFFTagSet.FILL_ORDER_LEFT_TO_RIGHT;
this.compression = BaselineTIFFTagSet.COMPRESSION_CCITT_RLE; // RLE
this.t4Options = 0; // Irrelevant as applies to T.4 only
this.oneD = 0; // One-dimensional
this.uncompressedMode = 0; // Not uncompressed mode
this.fillBits = 0; // No fill bits
this.t6Options = 0;
}
}
public void decodeRaw(byte[] b, int dstOffset,
int pixelBitStride, // will always be 1
int scanlineStride) throws IOException {
this.buffer = b;
this.w = srcWidth;
this.h = srcHeight;
this.bitsPerScanline = scanlineStride*8;
this.lineBitNum = 8*dstOffset;
this.data = new byte[byteCount];
this.bitPointer = 0;
this.bytePointer = 0;
this.prevChangingElems = new int[w + 1];
this.currChangingElems = new int[w + 1];
stream.seek(offset);
stream.readFully(data);
if (compression == BaselineTIFFTagSet.COMPRESSION_CCITT_RLE) {
decodeRLE();
} else if (compression == BaselineTIFFTagSet.COMPRESSION_CCITT_T_4) {
decodeT4();
} else if (compression == BaselineTIFFTagSet.COMPRESSION_CCITT_T_6) {
this.uncompressedMode = ((t6Options & 0x02) >> 1);
decodeT6();
} else {
throw new IIOException("Unknown compression type " + compression);
}
}
/**
* Invokes the superclass method and then sets instance variables on
* the basis of the metadata set on this decompressor.
*/
public void beginDecoding() {
super.beginDecoding();
if(metadata instanceof TIFFImageMetadata) {
TIFFImageMetadata tmetadata = (TIFFImageMetadata)metadata;
TIFFField f;
f = tmetadata.getTIFFField(BaselineTIFFTagSet.TAG_FILL_ORDER);
this.fillOrder = f == null ?
BaselineTIFFTagSet.FILL_ORDER_LEFT_TO_RIGHT : f.getAsInt(0);
f = tmetadata.getTIFFField(BaselineTIFFTagSet.TAG_COMPRESSION);
this.compression = f == null ?
BaselineTIFFTagSet.COMPRESSION_CCITT_RLE : f.getAsInt(0);
f = tmetadata.getTIFFField(BaselineTIFFTagSet.TAG_T4_OPTIONS);
this.t4Options = f == null ? 0 : f.getAsInt(0);
this.oneD = (t4Options & 0x01);
// uncompressedMode - haven't dealt with this yet.
this.uncompressedMode = ((t4Options & 0x02) >> 1);
this.fillBits = ((t4Options & 0x04) >> 2);
f = tmetadata.getTIFFField(BaselineTIFFTagSet.TAG_T6_OPTIONS);
this.t6Options = f == null ? 0 : f.getAsInt(0);
} else {
this.fillOrder = BaselineTIFFTagSet.FILL_ORDER_LEFT_TO_RIGHT;
this.compression = BaselineTIFFTagSet.COMPRESSION_CCITT_RLE; // RLE
this.t4Options = 0; // Irrelevant as applies to T.4 only
this.oneD = 0; // One-dimensional
this.uncompressedMode = 0; // Not uncompressed mode
this.fillBits = 0; // No fill bits
this.t6Options = 0;
}
}
public void decodeRaw(byte[] b, int dstOffset,
int pixelBitStride, // will always be 1
int scanlineStride) throws IOException {
this.buffer = b;
this.w = srcWidth;
this.h = srcHeight;
this.bitsPerScanline = scanlineStride*8;
this.lineBitNum = 8*dstOffset;
this.data = new byte[byteCount];
this.bitPointer = 0;
this.bytePointer = 0;
this.prevChangingElems = new int[w + 1];
this.currChangingElems = new int[w + 1];
stream.seek(offset);
stream.readFully(data);
if (compression == BaselineTIFFTagSet.COMPRESSION_CCITT_RLE) {
decodeRLE();
} else if (compression == BaselineTIFFTagSet.COMPRESSION_CCITT_T_4) {
decodeT4();
} else if (compression == BaselineTIFFTagSet.COMPRESSION_CCITT_T_6) {
this.uncompressedMode = ((t6Options & 0x02) >> 1);
decodeT6();
} else {
throw new IIOException("Unknown compression type " + compression);
}
}
public TIFFRLECompressor() {
super("CCITT RLE", BaselineTIFFTagSet.COMPRESSION_CCITT_RLE, true);
}
public TIFFRLECompressor() {
super("CCITT RLE", BaselineTIFFTagSet.COMPRESSION_CCITT_RLE, true);
}