Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fixes for using TiffImageWriter.replacePixels using bigTIFF #218

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ public void initialize(ImageInputStream stream,
TIFFIFD subIFD = new TIFFIFD(tagSets);

// XXX Use same ignore policy for sub-IFD fields?
subIFD.initialize(stream, ignoreUnknownFields);
subIFD.initialize(stream, ignoreUnknownFields, isBTIFF);
obj = subIFD;
stream.reset();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3390,7 +3390,7 @@ private TIFFIFD readIFD(int imageIndex) throws IOException {
TIFFIFD rootIFD = new TIFFIFD(tagSets);
// XXX Ignore unknown fields in metadata presumably because
// any fields needed to write pixels would be known?
rootIFD.initialize(stream, true);
rootIFD.initialize(stream, true, isBtiff);
stream.reset();

return rootIFD;
Expand Down Expand Up @@ -3455,8 +3455,7 @@ public void prepareReplacePixels(int imageIndex,
}

// Get the image dimensions.
f =
replacePixelsIFD.getTIFFField(BaselineTIFFTagSet.TAG_IMAGE_WIDTH);
f = replacePixelsIFD.getTIFFField(BaselineTIFFTagSet.TAG_IMAGE_WIDTH);
if(f == null) {
throw new IIOException("Cannot read ImageWidth field.");
}
Expand Down Expand Up @@ -3905,12 +3904,18 @@ public void replacePixels(RenderedImage image, ImageWriteParam param)
// Update Strip/TileOffsets and
// Strip/TileByteCounts fields.
stream.mark();
stream.seek(replacePixelsOffsetsPosition +
4*tileIndex);
stream.writeInt((int)nextSpace);
stream.seek(replacePixelsByteCountsPosition +
4*tileIndex);
stream.writeInt(numBytes);

if (isBtiff) {
stream.seek(replacePixelsOffsetsPosition + 8 * tileIndex);
stream.writeLong(nextSpace);
stream.seek(replacePixelsByteCountsPosition + 8 * tileIndex);
stream.writeLong(numBytes);
} else {
stream.seek(replacePixelsOffsetsPosition + 4 * tileIndex);
stream.writeInt((int)nextSpace);
stream.seek(replacePixelsByteCountsPosition + 4 * tileIndex);
stream.writeInt(numBytes);
}
stream.reset();

// Increment location of next available space.
Expand Down