09-09-2005, 09:08 PM
You have a picture of a certain width and height.
So the picture consists of an amount of pixels:
Each pixel takes up 3 or 4 bytes of memory, depending on your color depth (let's assume 32 bit here, so 4 bytes per pixel). Amount of space total for all pixels is:
However, the PUT format uses a 4 byte header to store the width and height of your image in. So the total required size becomes:
Note that this is in bytes the required size of your array.
So the picture consists of an amount of pixels:
Code:
pixels = width * height
Code:
spaceforpixels = pixels * 4
= width * height * 4
Code:
totalsize = spaceforpixels + 4
= width * height * 4 + 4