nothings / stb

stb single-file public domain libraries for C/C++
https://twitter.com/nothings
Other
26.84k stars 7.72k forks source link

Assertion failed while loading 32bit BMP #1325

Closed cyanskies closed 1 year ago

cyanskies commented 2 years ago

The following gets written to the console after calling stbi_load: Assertion failed: info.offset == s->callback_already_read + (int) (s->img_buffer - s->img_buffer_original) stb_image.h, line 5397

Here is the BMP that triggers the error example_bmp.zip.

cyanskies commented 2 years ago

Hi I've created a repo with the file and some code to load it. I mimic the same behaviour as SFML as that is where I experienced the original assertion error.

https://github.com/cyanskies/stb_recreate

The graphic was downloaded from a free game art repository(I don't remember which), it seems the original source for the image was 8bit, so it must have been converted along the way.

Using the latest stb in my repo above, stbi_load_from_callbacks() no longer asserts and the file is reported as having a bad offset.

Opening and saving the file with paint.net(forcing it to keep it as 32bit) doesn't seem to repair the file(it previews fine in windows and other image editors, but is still unloadable with stb).

I'm satisfied with the returned error, so I'll close this issue unless you want to try and make stb tolerate this file?

nothings commented 2 years ago

it opens correctly in mspaint and photoshop and FreeImage, so it's probably worth fixing it. it appears to have extra data in the header, and instead of skipping that data, stb_image throws an error.

sharmadhiraj86 commented 2 years ago

I would like to contribute to solve this issue. So if possible, can you please assign this issue to me and help me with some resources for the issue?

[i edited out the tag spam, but it's too late to stop the notification spam, sorry everybody -- nothings]

nothings commented 2 years ago

dude, why are you tagging a bunch of people? that's spam.

i don't use github assignment to outsider contributors, if you want to work on it, work on it. you can ask for help in the discussion forum, but no guarantee anybody will answer.

nothings commented 2 years ago

@sharmadhiraj86

Let me be clearer. The thing you did with the list of random contributors is spam and it is not cool and it is the kind of thing that will get you banned from this repository. You get one strike, if you do something like that again you're out.

Feel free to continue participating normally, or if that makes you uncomfortable feel free to stop, whatever, but I have better things to do than police the repository issue comments.

sharmadhiraj86 commented 2 years ago

Let me be clearer. The thing you did with the list of random contributors is spam and it is not cool and it is the kind of thing that will get you banned from this repository. You get one strike, if you do something like that again you're out.

Feel free to continue participating normally, or if that makes you uncomfortable feel free to stop, whatever, but I have better things to do than police the repository issue comments.

Sorry for that but I did not know whom to tag who will assign me the issue.

akx commented 2 years ago

@sharmadhiraj86 As Sean said, you don't need to be assigned. You're free to work on the issue, and open a PR that fixes things.

rygorous commented 1 year ago

A fix for this was just added on the dev branch. Will be in the next release.

rygorous commented 1 year ago

Fixed in 2.28.