Page MenuHome

Fix loading of indexed .bmp files
AbandonedPublic

Authored by Campbell Barton (campbellbarton) on Mar 10 2015, 3:31 PM.

Details

Summary

This patch fixes some issues with loading of indexed BMP files.
(1) It used an invalid offset to determine where the BMP data starts. This information is provided by the file info header, which was previously ignored entirely.
(2) It read from the palette as RGB even though it really contains BGR data.
(3) It did not support images of bit depths 1, 2 and 4. Some programs I worked with produce such images automatically when they notice that there are only a few colours in the image, so it would be nice if Blender supported this.

I can provide test .bmp files if needed.

Diff Detail

Event Timeline

rdb (rdb) updated this revision to Diff 3715.Mar 10 2015, 3:31 PM
rdb (rdb) retitled this revision from to Fix loading of indexed .bmp files.
rdb (rdb) updated this object.
rdb (rdb) set the repository for this revision to rB Blender.
rdb (rdb) added a project: Images & Movies.

Would be nice to have a set of files which fails to load, so we can test the changes and so.

source/blender/imbuf/intern/bmp.c
209

That's a bit weird, bitoffs is already 0 as far as i can follow the if statement above.

I don't know how to upload a file to Differential (it tells me to "drag" it, but I don't use a graphical file manager, so I don't know where I'd drag it from).

I uploaded it here:
http://rdb.name/indexed-bmps.zip

Thanks!

source/blender/imbuf/intern/bmp.c
209

Yes, it's 0; this line sets it to 8 so that the next iteration of the loop starts at the most significant bits of the next byte.

source/blender/imbuf/intern/bmp.c
209

Oh geez, i've read it at zero here, bummer! So no issues what's so ever from my side then.