Reputation: 19526
I have a simple image that stores the width, height, pixelformat, and some other things that I'm not sure about, and then followed by the pixel data.
I've been told the pixel format is RGBA32, and that the rest of the data is just the pixel data.
What's the formula for calculating it? From my understanding, 8 bits are required for each of the RGBA colors, so 4 bytes are required for each pixel.
So then I would conclude the size of the pixel array is width * height * 4, but that wasn't enough.
Upvotes: 0
Views: 2955
Reputation: 3815
A 64px by 64px BMP with RGBA32 will typically be 16440 bytes (presuming BITMAPV3INFOHEADER). 56 bytes for the header, 16384 bytes for the pixel data (which is 64*64*4). The header size can vary though and be as large as 124 bytes (BITMAPV5HEADER) presuming a standard BMP.
I would guess that you've got one or more of the following to account for your extra ~5376 (21760 - 16384) bytes:
In any case, I would first check the last 16384 (64 * 64 * 4) bytes of data which is likely where your image data is (if this format at all takes after the BMP format and doesn't have some trailing metadata or ICC profile or integrity check). On a side note, RGBA data is typically stored with the alpha byte first (ARGB).
Might be worth taking a look at this diagram of the BMP file format just to familiarize yourself with a common image format's structure.
Upvotes: 1