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

 

OpenGL ES  纹理的宽和高都要是2次幂数, 以刚才的例子来说, 假如 start.png 本身是 480x320, 但在载入内存後, 它其实会被变成一张 512x512 的纹理, 而start.png 则由 101x131 变成 128x256, 默认情况下面,当你在cocos2d里面加载一张图片的时候,对于每一个像素点使用4个byte来表示--1个byte(8位)代表red,另外3个byte分别代表green、blue和alpha透明通道。这个就简称RGBA8888

图像宽度(width)×图像高度(height)×每一个像素的位数(bytes per pixel) = 内存大小

  此时,如果你有一张512×512的图片,那么当你使用默认的像素格式去加载它的话,那么将耗费

  512×512×4=1MB

1MB = 1024 KB= 1024*1024 B

 

 

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)
posted on 2013-10-31 11:56  凌度  阅读(13199)  评论(0编辑  收藏  举报