How to calculate image size by image pixels

图像大小在相机下通常表现为“像素”,例如1200万像素的相机,一张图片是3000*4000;
而保存成bmp的无压缩格式图片时,存到本地上我们更加习惯的是以“内存”的方式来描述大小。

那么是如何通过图片的像素大小来计算保存后的内存大小呢?
下面给出一组计算公式:

Image memory size = pixel width × pixel height × bit depth ÷ 1024 ÷ 1024 ÷ 8 (in MB)

Remarks: In general, save as a grayscale image with a bit depth of 8; save as a color image with a bit depth of 24; for details, you can right-click on the computer to view the properties. The two 1024 in the formula are to convert the unit into MB (1MB =
1024KB )

insert image description here

例如上述图片,是一张彩色图,那么
内存大小=4000×3000×24÷1024÷1024÷8= 34.3 MB

Guess you like

Origin blog.csdn.net/weixin_44650358/article/details/127074725