图像内存使用

时间:2014-06-19 07:01:40

标签: image actionscript-3 flex flex3 flex4.5

我有26,4KB的图像。它由Frame bellow类加载。为什么Flex的Profiling Tool显示此Frame实例的使用量为1388KB。

public class Frame extends Group
    {
        public function Frame(source:Object)// image with 26,4K
        {           
            var image:BitmapImage;
            image = new BitmapImage();
            image.smooth = true;
            image.source = source;
            this.addElement(image);         
        }   
    }

1 个答案:

答案 0 :(得分:1)

BitmapImages本质上是一个未压缩的矩形数组,包含确定像素颜色的字节。

我想您的输入文件是JPG/JPEGPNGGIF? (基本上,它被压缩了。)

想象一下图像100px by 100px, 32bit RGBA colors(红色/绿色/蓝色/ Alpha)。

BitmapImage 的内存要求将在100 * 100 * (32 / 8)(X * Y * bytesPerPixel)= 40K字节附近。但是 SAME 图像作为JPG可能会压缩到3K或者其他东西。 (或GIF,或PNG等)

必须将其存储为某个位图,以便可以将其复制(blitted)到视频内存中进行显示。或许flex可以使用/尝试其他图像存储类型吗?