图像的内存大小 [英] Memory size of an image

查看:131
本文介绍了图像的内存大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何计算图片框中包含的图像的内存大小?

How can i calculate the memory size of an image enclosed in a picture box?

推荐答案

如果知道图像的位置,则可以执行以下操作:

If you know the location of the image then you can do the following:

FileInfo imageInfo = new FileInfo(imagePath);

int sizeInBytes = imageInfo.Length;



如果您自己创建图像,并且知道以像素为单位的宽度和高度以及颜色深度,则可以使用以下公式来计算图像的大小(以千字节为单位).

除以8将为您提供以字节为单位的答案
除以8 * 1024可以得到Kb的答案
除以8 * 1024 * 1024可得到Mb的答案



if you are creating the image yourself and you know the width and height in pixels aswell as the colour depth then you can use the following formula to work out the size of the image in kilobytes.

Division by 8 will give you an answer in bytes
Division by 8*1024 will give you an answer in Kb
Division by 8*1024*1024 will give you an answer in Mb

            width in pixels × height in pixels × colour depth
SizeInKb = ___________________________________________________

                        8 × 1024




下表是色深表




The following is a table of colour depth

Colour Depth in Bits    Number of Colours   Number of Colours calculations

1                         2                   2^1 = 2
 
2                         4                   2^2 = 4 

3                         8                   2^3 = 8 

4                         16                  2^4 = 16

5                         32                  2^5 = 32

6                         64                  2^6 = 64

7                         128                 2^7 = 128

8                         256                 2^8 = 256

16                        65536               2^16 = 65563

24                        16777216            2^24 = 16777216  

32                        4294967296          2^32 = 4294967296



etc



etc


将图像转换为字节数组.然后以字节为单位获取大小,并以Kb或Mb进行计算.
Convert image to Array of bytes. Then get the size in byte and calculate it in Kb or Mb.


这篇关于图像的内存大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆