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

Invalid DIB size calculation #3

Open
ForNeVeR opened this issue Apr 1, 2023 · 1 comment
Open

Invalid DIB size calculation #3

ForNeVeR opened this issue Apr 1, 2023 · 1 comment

Comments

@ForNeVeR
Copy link

ForNeVeR commented Apr 1, 2023

DeviceIndependentBitmap currently doesn't take into account the color palette stored in the DIB, which makes the size calculation incorrect. Currently it reads:

  • read 40-byte header
  • read (seemingly properly calculated amount of) data bytes into Data

But it should:

  • read 40-byte header
  • read (header.ColorsUsed ?? 1 << header.BitCount) * 4 bytes into Colors
  • read same amount of data into Data

Here's a compressed example of a file that reads incorrectly by the library: _bm0.zip.

ForNeVeR added a commit to ForNeVeR/wmf that referenced this issue Apr 1, 2023
Without this, DIBs are read incorrectly: part of the color palette gets
mixed with the actual file data, and last bytes from the data get
completely lost.
@ForNeVeR
Copy link
Author

ForNeVeR commented Apr 1, 2023

I've sent a PR with a fix to the fork I use: wieslawsoltes#1. Still not sure what's the story with the fork and NuGet, though. I'm ready to send a PR to this repo as well if you want.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant