stb icon indicating copy to clipboard operation
stb copied to clipboard

Assertion failed while loading 32bit BMP

Open cyanskies opened this issue 2 years ago • 7 comments

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 avatar May 06 '22 10:05 cyanskies

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?

cyanskies avatar Sep 10 '22 09:09 cyanskies

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.

nothings avatar Sep 10 '22 11:09 nothings

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]

sharmadhiraj86 avatar Sep 10 '22 14:09 sharmadhiraj86

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 avatar Sep 10 '22 20:09 nothings

@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.

nothings avatar Sep 10 '22 20:09 nothings

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.

sharmadhiraj86 avatar Sep 11 '22 06:09 sharmadhiraj86

@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.

akx avatar Sep 11 '22 19:09 akx

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

rygorous avatar Jan 23 '23 02:01 rygorous

Fixed in 2.28.

rygorous avatar Jan 29 '23 23:01 rygorous