下面列出了javax.imageio.plugins.tiff.BaselineTIFFTagSet#COMPRESSION_NONE 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public boolean canReplacePixels(int imageIndex) throws IOException {
if (getOutput() == null) {
throw new IllegalStateException("getOutput() == null!");
}
TIFFIFD rootIFD = readIFD(imageIndex);
TIFFField f = rootIFD.getTIFFField(BaselineTIFFTagSet.TAG_COMPRESSION);
int compression = f.getAsInt(0);
return compression == BaselineTIFFTagSet.COMPRESSION_NONE;
}
private int getCompression() {
TIFFField f
= imageMetadata.getTIFFField(BaselineTIFFTagSet.TAG_COMPRESSION);
if (f == null) {
return BaselineTIFFTagSet.COMPRESSION_NONE;
} else {
return f.getAsInt(0);
}
}
public boolean isRandomAccessEasy(int imageIndex) throws IOException {
if (currIndex != -1) {
seekToImage(currIndex);
return getCompression() == BaselineTIFFTagSet.COMPRESSION_NONE;
} else {
return false;
}
}
public boolean canReplacePixels(int imageIndex) throws IOException {
if (getOutput() == null) {
throw new IllegalStateException("getOutput() == null!");
}
TIFFIFD rootIFD = readIFD(imageIndex);
TIFFField f = rootIFD.getTIFFField(BaselineTIFFTagSet.TAG_COMPRESSION);
int compression = f.getAsInt(0);
return compression == BaselineTIFFTagSet.COMPRESSION_NONE;
}
private int getCompression() {
TIFFField f
= imageMetadata.getTIFFField(BaselineTIFFTagSet.TAG_COMPRESSION);
if (f == null) {
return BaselineTIFFTagSet.COMPRESSION_NONE;
} else {
return f.getAsInt(0);
}
}
public boolean isRandomAccessEasy(int imageIndex) throws IOException {
if (currIndex != -1) {
seekToImage(currIndex);
return getCompression() == BaselineTIFFTagSet.COMPRESSION_NONE;
} else {
return false;
}
}
public void prepareReplacePixels(int imageIndex,
Rectangle region) throws IOException {
synchronized(replacePixelsLock) {
// Check state and parameters vis-a-vis ImageWriter specification.
if (stream == null) {
throw new IllegalStateException("Output not set!");
}
if (region == null) {
throw new IllegalArgumentException("region == null!");
}
if (region.getWidth() < 1) {
throw new IllegalArgumentException("region.getWidth() < 1!");
}
if (region.getHeight() < 1) {
throw new IllegalArgumentException("region.getHeight() < 1!");
}
if (inReplacePixelsNest) {
throw new IllegalStateException
("In nested call to prepareReplacePixels!");
}
// Read the IFD for the pixel replacement index.
TIFFIFD replacePixelsIFD = readIFD(imageIndex);
// Ensure that compression is "none".
TIFFField f =
replacePixelsIFD.getTIFFField(BaselineTIFFTagSet.TAG_COMPRESSION);
int compression = f.getAsInt(0);
if (compression != BaselineTIFFTagSet.COMPRESSION_NONE) {
throw new UnsupportedOperationException
("canReplacePixels(imageIndex) == false!");
}
// Get the image dimensions.
f =
replacePixelsIFD.getTIFFField(BaselineTIFFTagSet.TAG_IMAGE_WIDTH);
if(f == null) {
throw new IIOException("Cannot read ImageWidth field.");
}
int w = f.getAsInt(0);
f =
replacePixelsIFD.getTIFFField(BaselineTIFFTagSet.TAG_IMAGE_LENGTH);
if(f == null) {
throw new IIOException("Cannot read ImageHeight field.");
}
int h = f.getAsInt(0);
// Create image bounds.
Rectangle bounds = new Rectangle(0, 0, w, h);
// Intersect region with bounds.
region = region.intersection(bounds);
// Check for empty intersection.
if(region.isEmpty()) {
throw new IIOException("Region does not intersect image bounds");
}
// Save the region.
replacePixelsRegion = region;
// Get the tile offsets.
f = replacePixelsIFD.getTIFFField(BaselineTIFFTagSet.TAG_TILE_OFFSETS);
if(f == null) {
f = replacePixelsIFD.getTIFFField(BaselineTIFFTagSet.TAG_STRIP_OFFSETS);
}
replacePixelsTileOffsets = f.getAsLongs();
// Get the byte counts.
f = replacePixelsIFD.getTIFFField(BaselineTIFFTagSet.TAG_TILE_BYTE_COUNTS);
if(f == null) {
f = replacePixelsIFD.getTIFFField(BaselineTIFFTagSet.TAG_STRIP_BYTE_COUNTS);
}
replacePixelsByteCounts = f.getAsLongs();
replacePixelsOffsetsPosition =
replacePixelsIFD.getStripOrTileOffsetsPosition();
replacePixelsByteCountsPosition =
replacePixelsIFD.getStripOrTileByteCountsPosition();
// Get the image metadata.
replacePixelsMetadata = new TIFFImageMetadata(replacePixelsIFD);
// Save the image index.
replacePixelsIndex = imageIndex;
// Set the pixel replacement flag.
inReplacePixelsNest = true;
}
}
public TIFFLSBCompressor() {
super("", BaselineTIFFTagSet.COMPRESSION_NONE, true);
}
public TIFFNullCompressor() {
super("", BaselineTIFFTagSet.COMPRESSION_NONE, true);
}
public void prepareReplacePixels(int imageIndex,
Rectangle region) throws IOException {
synchronized(replacePixelsLock) {
// Check state and parameters vis-a-vis ImageWriter specification.
if (stream == null) {
throw new IllegalStateException("Output not set!");
}
if (region == null) {
throw new IllegalArgumentException("region == null!");
}
if (region.getWidth() < 1) {
throw new IllegalArgumentException("region.getWidth() < 1!");
}
if (region.getHeight() < 1) {
throw new IllegalArgumentException("region.getHeight() < 1!");
}
if (inReplacePixelsNest) {
throw new IllegalStateException
("In nested call to prepareReplacePixels!");
}
// Read the IFD for the pixel replacement index.
TIFFIFD replacePixelsIFD = readIFD(imageIndex);
// Ensure that compression is "none".
TIFFField f =
replacePixelsIFD.getTIFFField(BaselineTIFFTagSet.TAG_COMPRESSION);
int compression = f.getAsInt(0);
if (compression != BaselineTIFFTagSet.COMPRESSION_NONE) {
throw new UnsupportedOperationException
("canReplacePixels(imageIndex) == false!");
}
// Get the image dimensions.
f =
replacePixelsIFD.getTIFFField(BaselineTIFFTagSet.TAG_IMAGE_WIDTH);
if(f == null) {
throw new IIOException("Cannot read ImageWidth field.");
}
int w = f.getAsInt(0);
f =
replacePixelsIFD.getTIFFField(BaselineTIFFTagSet.TAG_IMAGE_LENGTH);
if(f == null) {
throw new IIOException("Cannot read ImageHeight field.");
}
int h = f.getAsInt(0);
// Create image bounds.
Rectangle bounds = new Rectangle(0, 0, w, h);
// Intersect region with bounds.
region = region.intersection(bounds);
// Check for empty intersection.
if(region.isEmpty()) {
throw new IIOException("Region does not intersect image bounds");
}
// Save the region.
replacePixelsRegion = region;
// Get the tile offsets.
f = replacePixelsIFD.getTIFFField(BaselineTIFFTagSet.TAG_TILE_OFFSETS);
if(f == null) {
f = replacePixelsIFD.getTIFFField(BaselineTIFFTagSet.TAG_STRIP_OFFSETS);
}
replacePixelsTileOffsets = f.getAsLongs();
// Get the byte counts.
f = replacePixelsIFD.getTIFFField(BaselineTIFFTagSet.TAG_TILE_BYTE_COUNTS);
if(f == null) {
f = replacePixelsIFD.getTIFFField(BaselineTIFFTagSet.TAG_STRIP_BYTE_COUNTS);
}
replacePixelsByteCounts = f.getAsLongs();
replacePixelsOffsetsPosition =
replacePixelsIFD.getStripOrTileOffsetsPosition();
replacePixelsByteCountsPosition =
replacePixelsIFD.getStripOrTileByteCountsPosition();
// Get the image metadata.
replacePixelsMetadata = new TIFFImageMetadata(replacePixelsIFD);
// Save the image index.
replacePixelsIndex = imageIndex;
// Set the pixel replacement flag.
inReplacePixelsNest = true;
}
}
public TIFFLSBCompressor() {
super("", BaselineTIFFTagSet.COMPRESSION_NONE, true);
}
public TIFFNullCompressor() {
super("", BaselineTIFFTagSet.COMPRESSION_NONE, true);
}