fuzziqersoftware / phosg

C++ helpers for some common tasks
18 stars 17 forks source link

BMP: Write full V5 header #17

Closed Kristine1975 closed 1 year ago

Kristine1975 commented 1 year ago

This:

  1. more-or-less-correctly[*] sets the image's color space to sRGB
  2. results in a correct header, which avoids errors when loading the BMP e.g. with ImageMagick ("invalid chromaticities")

Also fixed (but not tested, as BMP loading doesn't seem to be used): when loading a BMP file, use the file's header to determine how large it is instead of just assuming it's a V4 header.

[*] MacOS Classic doesn't use sRGB (which didn't exist until 1996), but a gamma value of 1.8 instead (sRGB is approximately 2.2). So saving image resources in sRGB color space changes the colors slightly. Technically correct would be to store the color space information in the BMP by writing a V5 header with:

(I hope I got the chromacities right...) (I'm just noting these values down here so they don't get lost)