If I have an image of resolutin of 512 * 512,
and this image is indexed with 256 color values,
how to calulate the size of the image (file size ) ?
The image itself can be calculate as follow
256 can be stored in one byte. So one pixel is 1 byte.
You have a 512*512 pixels.
512*512*1 = 262144
But on your disk, it will take a little more than those 262ko, as you have to count the bytes used for the file meta-information, and the color palette.
Check out the bmp header spec if you need more informations.