Page MenuHome

reduce size of exported BW bmps, cleanup
Needs ReviewPublic

Authored by James Fulop (Yam) on Dec 22 2019, 9:52 PM.



Addressing this low priority TODO task T71898: Grayscale BMP output files are 24-bit, not 8-bit

This change makes it so exported bmp's come out at 8bpp instead of 24bpp, cutting file size by two thirds.

This was a little more complicated than you'd expect because the BMP spec expects that 8bpp files use a color palette, so we have to spam out a color palette that is just every grayscale value.

On the cleanup side, I thought things read nicer with underscores rather than running the words together in lowercase. How it was previously didn't seem in-style but I've only looked at a very small portion of blender C code. I also removed some hyperlinks in comments that are now dead.

I've attached an exported file with these changes in place.

I'm not 100% sure if this is a good idea because not all image viewers can import it correctly, in particular Windows' default image viewer Photos. Here's the testing I tried on my Windows 10 machine.

works in:

  • blender import
  • irfanviewer
  • gimp
  • renderdoc
  • imageglass
  • visual studio 2017 (it actually has an image viewer built into it??)
  • chrome

fails in:

  • Photos (default Windows 10 image viewer for this type)
  • Paint
  • Paint 3D

Happy to let this sit until Bcon1.

Diff Detail

Event Timeline

Campbell Barton (campbellbarton) requested changes to this revision.Dec 24 2019, 2:48 AM

Thanks for working on this patch,

Note that mixing in cleanups with new features should be avoided, it slows down code review and increases chance we miss meaningful changes.

Requesting changes (removal of cleanup + comments inline).


This value may be 32, which is currently never written, this patch should only handle the greyscale case.

Suggest to only write fixed values based on is_grayscale.

This revision now requires changes to proceed.Dec 24 2019, 2:48 AM

Thanks for looking Campbell.

I've stripped the patch down to just whats necessary.
Addressed your comment regarding the planes var.
I also noticed I had slipped in a // style comment, fixed that.