Subject: Re: Windows freeware to lock in a 3: or 4:3 aspect ratio for cropping
| I know that BMP stores image data uncompressed. But I also know that it
| stores a 24bpp (RGB) pixel in a DWORD (4 bytes) storage. That's 25% waste.
Not actually. It requires a scan line divisble by 4. Maybe
that's what you're thinking of. But that's just for building
the file. As a DIB it's just 3 bytes per pixel. If you create
a 10x10 white BMP and save to disk you can see it clearly.
Each horizontal scan line is 30 bytes. 10 pixels at 3 bytes
each. If you look at it in a hex editor you'll see 2 null bytes
after each 30 FF bytes, rounding up each line to 32 bytes.
The width and height are in the header, so Windows will
unpack it accordingly. And the loaded DIB will be just 300
bytes of value 255.
Thus: 10x10 BMP @ 374 bytes. 54 byte header. 300 bytes
for 100 pixels of data. 20 bytes scan line padding. If the
image is something like 800x600 the padding, if any, will
be negligible. In fact, with 800 x 600 it's zero:
800 pixels wide x 3 bytes per pixel = 2400 bytes per scan
line, which divides evenly by 4.
The pixel value can be handled as a DWORD/long integer
but it's only actually 3 bytes of data. One byte for each
RGB. (Notice the color picker ion any graphic editor.
Typically it's a 6 character hex code. 3 bytes. 24-bit.
A PNG has to store 4 bytes for the alpha channel
AKA transparency percentage value of the pixel. But
for BMP it's just 3 pixels.