zoukankan      html  css  js  c++  java
  • 图片占用内存计算

    图像占用内存的公式是: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)
  • 相关阅读:
    xBIM 基本的模型操作
    xBIM 应用与学习 (二)
    xBIM 应用与学习 (一)
    ABP WebApi 加载错误
    ABP 数据迁移
    AutoDesk Forge 获取令牌认证
    IIS 加载 JSON 错误 404 解决办法
    ASP.NET MVC 5 ABP DataTables (二)
    ASP.NET MVC 5 ABP DataTables (一)
    Windows10卡顿,磁盘 内存占用100%或比较多
  • 原文地址:https://www.cnblogs.com/linn/p/3398888.html
Copyright © 2011-2022 走看看