图片在内存中占用的大小

来源:互联网 发布:mac os 系统更新 编辑:程序博客网 时间:2024/06/05 00:31

       图片占用内存的公式: numBytes = width  * height * bitsPerPixel / 8;

       OpenGL ES 纹理的宽和高都是按照 2 的次幂来计算的,一张图片打实际大小是 480 * 320 ,在内存中的实际大小是成为一张纹理为 512 * 512的。

默认情况下,cocos2dx 加载一张图片的时候,对于每一个像素点使用4个Byte来表示 1 个Byte(8位)代表Red,另外 3 个Byte分别代表 Green, Blue和 Alpha 透明通道,即 RGBA8888。

       现在计算 512 * 512 * 32 / 8 =  1 MB(1 MB = 1024 KB = 1024B)

上面计算的也就是一张纹理大小为 512 * 512 的图片所在内存中所占用的内存

 

PVRTC4: Compressed format, 4 bits per pixel, ok image quality
PVRTC2: Compressed format, 2 bits per pixel, poor image quality
一般pvr格式文件的图像格式有:
RGBA8888: 32-bit texture with alpha channel, best image quality
RGBA4444: 16-bit texture with alpha channel, good image quality
RGB565: 16-bit texture without alpha channel, good image quality but no alpha (transparency)
0 0
原创粉丝点击