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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for decoding tiled tiff images #2290
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This all looks great! Nice work!
IExifValue tilesByteCountsExifValue = tags.GetValueInternal(ExifTag.TileByteCounts); | ||
if (tilesOffsetsExifValue is null) | ||
{ | ||
// Note: This is against the spec, but libTiff seems to handle it this way. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've come to believe there is not a single image spec over 10 years old that hasn't been blatantly trampled on
|
||
try | ||
{ | ||
int bytesPerTileRow = ((tileWidth * bitsPerPixel) + 7) / 8; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
int bytesPerTileRow = ((tileWidth * bitsPerPixel) + 7) / 8; | |
int bytesPerTileRow = (int)((((uint)tileWidth * (uint)bitsPerPixel) + 7) / 8); |
C#: uglier
Asm: nicer
Or work with uint
generally here (instead of int
), then the casts aren't needed.
int bytesPerRow = ((width * bitsPerPixel) + 7) / 8; | ||
int bytesPerTileRow = ((tileWidth * bitsPerPixel) + 7) / 8; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
|
||
int tileBufferOffset = 0; | ||
uncompressedPixelBufferOffset += bytesPerTileRow * tileX; | ||
int bytesToCopy = isLastHorizontalTile ? ((bitsPerPixel * remainingPixelsInRow) + 7) / 8 : bytesPerTileRow; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same.
} | ||
} | ||
|
||
int bytesPerRow = ((width * bitsPerPixel) + 7) / 8; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could also use a helper-method for this, which has all the ugly casts in it, so the call-sites remain clean and descriptive.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added a helper method for this: 8fe8948
Prerequisites
Description
This PR adds support for decoding tiff images which arrange the pixel data in tiles rather then strips.