-
-
Notifications
You must be signed in to change notification settings - Fork 888
Decoding Bitmaps with BITFIELDS masks #796
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
Decoding Bitmaps with BITFIELDS masks #796
Conversation
… infos for the BITFIELDS compression
…s for V4 are zero anyway.
Codecov Report
@@ Coverage Diff @@
## master #796 +/- ##
=========================================
Coverage ? 88.81%
=========================================
Files ? 1012
Lines ? 43447
Branches ? 3130
=========================================
Hits ? 38588
Misses ? 4159
Partials ? 700
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #796 +/- ##
==========================================
- Coverage 88.83% 88.76% -0.08%
==========================================
Files 1014 1014
Lines 43703 43999 +296
Branches 3124 3165 +41
==========================================
+ Hits 38824 39055 +231
- Misses 4178 4221 +43
- Partials 701 723 +22
Continue to review full report at Codecov.
|
|
I think this one is ready for review now. One note about the 16 Bits per pixel case: only bit masks with 5 or 6 bits are supported, because according to: http://www.fileformat.info/format/bmp/egff.htm. Windows 95 only supports the RGB555 and RGB565 pixel types. Bitmaps with other bitmasks may be theoretically possible, but i do not really think they can be found in the wild. |
JimBobSquarePants
left a comment
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 looks awesome! Just a couple of questions before we can continue.
…er for Rgba321010102
…el correctly: For V3 bitmaps, the alpha channel will be ignored during encoding
|
@brianpopow Great work! This all looks good to me so once it's built I'll merge it. I took the liberty to fix #732 here also since it was blocking your tests. |
|
@JimBobSquarePants: Thank you! We are getting close to be able to decode all bitmaps from the "good" category from: http://entropymine.com/jason/bmpsuite/bmpsuite/html/bmpsuite.html Only RLE4 is left now. I will do that next. |
|
Ace! Looking forward to it. Thanks again! |
* decoding bitmaps with Bitfields masks * added testcases for Bitfields bitmaps * added parsing of the complete bitmap V4 header to get the color masks infos for the BITFIELDS compression * writing now explicitly a Bitamp v3 header (40 bytes) * added test image for issue SixLabors#735 * fixed rescaling 5-bit / 6-bit to 0 - 255 range * BitmapEncoder now writes BMP v4 header * using MemoryMarshal.Cast to simplify parsing v4 header * added testcases for bitmap v3, v4, v5 * Bitmap encoder writes again V3 header instead of V4. Additional fields for V4 are zero anyway. * added parsing of special case for 56 bytes headers * using the alpha mask in ReadRgb32BitFields() when its present * added support for bitmasks greater then 8 bits per channel * using MagickReferenceDecoder reference decoder for the test with 10 bits pixel masks * changed bitmap constants to hex * added enum for the bitmap info header type * added support for 52 bytes header (same as 56 bytes without the alpha mask) * clarified comment with difference between imagesharp and magick decoder for Rgba321010102 * BmpEncoder now writes a V4 info header and uses BITFIELDS compression * workaround for issue that the decoder does not decode the alpha channel correctly: For V3 bitmaps, the alpha channel will be ignored during encoding * Fix SixLabors#732
Prerequisites
Description
This PR adds to the BMP decoder the ability to decode Bitmaps with the Compression type BITFIELDS. For bitmap V3 (40 bytes), color masks are followed after the BitmapInfo header.
For bitmap >= V4, this information is stored inside the BitmapInfo header. To be able to get this info, i added parsing V4 information headers.
This fixes #735 and also fixes #732