• 图片占用内存计算


    图像占用内存的公式是: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)
  • 相关阅读:
    2.由浅入深解析 SimpleDateFormat
    7.如何在Maven项目中引入自己的jar包
    6.Java英文缩写详解
    6.JXL操作Excel
    5.Apache POI使用详解
    4.Properties文件的加载和使用
    3.java.util.logging.Logger使用详解
    2.使用dom4j解析XML文件
    jdk、jre、spring、java ee、java se
    JVM架构
  • 原文地址:https://www.cnblogs.com/fwycmengsoft/p/3656605.html
Copyright © 2020-2023  润新知