yigolden / TiffLibrary

C# library for decoding and encoding Tag Image File Format (TIFF) files.
MIT License
58 stars 16 forks source link

Issue decoding YCbCr #7

Closed brianpopow closed 2 years ago

brianpopow commented 2 years ago

I found an issue with decoding some YCbCr. For example the following images are attached as zip: flower-ycbcr.zip

The output looks like this: output

The issue is that the image will be padded when the width or height is not a multiple of the subsampling according to TIFF Technical Note #2. At the very bottom of the text:

If ImageWidth and ImageLength are not multiples of
If ImageWidth and ImageLength are not multiples of
ChromaSubsampleHoriz and ChromaSubsampleVert respectively, then the
source data shall be padded to the next integer multiple of these
values before downsampling.

This TiffReverseChromaSubsampling8Middleware.cs file needs to be changed and padding added to width and height. Unfortunately i dont know the codebase good enough to provide a PR.