8000 Bug in BMP Decoding for 256x256 icons: Incorrect width and height in bitmap header · Issue #4 · fcjr/geticon · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Bug in BMP Decoding for 256x256 icons: Incorrect width and height in bitmap header #4

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

Open
x4lva opened this issue Oct 20, 2024 · 2 comments

Comments

@x4lva
Copy link
x4lva commented Oct 20, 2024

Hello,

I've encountered an issue when decoding BMP images for icons with a 256x256 resolution. It appears that the library does not handle icons of this size correctly, result is an empty image.

For icons with a 256x256 resolution, the library sets the bmpHeader.Width and bmpHeader.Height values to 0 due to the ICO format's convention of using 0 to represent 256. This leads to an invalid BMP header being generated, as the width and height are set to 0, causing the decoded image to be empty.

bmpHeader := &bitmapFileHeader{
      Signature:    [2]byte{'B', 'M'},
      FileSize:     14 + 40 + uint32(len(imgData)),
      DataOffset:   dataOffset,
      Size:         40,
      Width:        uint32(bestEntry.BWidth),    // Problem here 
      Height:       uint32(bestEntry.BHeight),
      Planes:       bestEntry.WPlanes,
      BitsPerPixel: bestEntry.WBitCount,
      ColorsUsed:   uint32(bestEntry.BColorCount),
}

Steps to Reproduce:
Attempt to get icon from JetBrains Goland executable file

Thank you

@fcjr
Copy link
Owner
fcjr commented Oct 23, 2024

Hey @x4lva looks like you're correct, thanks for the report! I will try and push a fix this week or would welcome a PR if you are so inclined :)

@x4lva
Copy link
Author
x4lva commented Oct 27, 2024

Hi, sure, will create PR tomorrow!

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

2 participants
0