Cocos2d 查看 pvr 图片的详细格式

原文链接:http://blog.csdn.net/yang3wei/article/details/7484222

发现一个问题,伙计交过来的pvr图片,我没法确切的知道他到底使用了哪种像素格式。

想到一个办法,可以在程序加载的时候打印出一些信息来得到这些信息。

主要修改 CCTexturePVR.m 这个文件,先看看pvr支持那些像素格式:

[cpp]  view plain copy
  1. #import <Availability.h>  
  2.   
  3. #import <zlib.h>  
  4.   
  5. #import "CCTexturePVR.h"  
  6. #import "ccMacros.h"  
  7. #import "CCConfiguration.h"  
  8. #import "Support/ccUtils.h"  
  9. #import "Support/CCFileUtils.h"  
  10. #import "Support/ZipUtils.h"  
  11. #import "Support/OpenGL_Internal.h"  
  12.   
  13. #pragma mark -  
  14. #pragma mark CCTexturePVR  
  15.   
  16. #define PVR_TEXTURE_FLAG_TYPE_MASK  0xff  
  17. #define PVR_TEXTURE_FLAG_FLIPPED_MASK 0x10000  
  18.   
  19. static char gPVRTexIdentifier[4] = "PVR!";  
  20.   
  21. enum  
  22. {  
  23.     kPVRTextureFlagTypeRGBA_4444= 0x10,  
  24.     kPVRTextureFlagTypeRGBA_5551,  
  25.     kPVRTextureFlagTypeRGBA_8888,  
  26.     kPVRTextureFlagTypeRGB_565,  
  27.     kPVRTextureFlagTypeRGB_555,             // unsupported  
  28.     kPVRTextureFlagTypeRGB_888,             // unsupported  
  29.     kPVRTextureFlagTypeI_8,  
  30.     kPVRTextureFlagTypeAI_88,  
  31.     kPVRTextureFlagTypePVRTC_2,  
  32.     kPVRTextureFlagTypePVRTC_4,   
  33.     kPVRTextureFlagTypeBGRA_8888,  
  34.     kPVRTextureFlagTypeA_8,  
  35. };  
简要介绍一下,比较常用的格式有:

RGBA_8888 没像素占用4字节内存,还原度最高,纹理质量最高。

RGBA_4444 每像素占用2字节内存,背景图采用此类型较优

RGBA_5551 每像素占用2字节内存,如上

RGBA_565  每像素占用2字节内存,如上(4444,5551,565依据对透明度的不同要求做不同选择)~

RGBA_888 每像素占用3字节,不包含透明度的图片用这种像素格式是最优的。

PVRTC_4,PVRTC_2 每像素占4bit,2bit,效果还是相当不错的,不过占用的内存将为8888的16分之1。

不过,耗用如此低,对像素质量也不要报太高期望了。


解题,主要修改 CCTexturePVR.m 的 -unpackPVRData:PVRLen: 方法:

在方法末 return success;这句代码之前添加如下代码:

NSLog(@"width=%d, height=%d, formatFlags=0x%2x"width_height_, formatFlags);

[java]  view plain copy
  1. GNU gdb 6.3.50-20050815 (Apple version gdb-1708) (Fri Sep 16 06:56:50 UTC 2011)  
  2. Copyright 2004 Free Software Foundation, Inc.  
  3. GDB is free software, covered by the GNU General Public License, and you are  
  4. welcome to change it and/or distribute copies of it under certain conditions.  
  5. Type "show copying" to see the conditions.  
  6. There is absolutely no warranty for GDB.  Type "show warranty" for details.  
  7. This GDB was configured as "--host=i386-apple-darwin --target=arm-apple-darwin".tty /dev/ttys000  
  8. target remote-mobile /tmp/.XcodeGDBRemote-280-57  
  9. Switching to remote-macosx protocol  
  10. mem 0x1000 0x3fffffff cache  
  11. mem 0x40000000 0xffffffff none  
  12. mem 0x00000000 0x0fff none  
  13. [Switching to process 7171 thread 0x1c03]  
  14. [Switching to process 7171 thread 0x1c03]  
  15. sharedlibrary apply-load-rules all  
  16. 2012-04-21 14:18:12.659 GameSceneEx[78875:707] width=1024, height=1024, formatFlags=0x19  
  17. 2012-04-21 14:18:12.706 GameSceneEx[78875:707] width=512, height=1024, formatFlags=0x10  
  18. 2012-04-21 14:18:12.863 GameSceneEx[78875:707] width=512, height=1024, formatFlags=0x10  
如上控制台输出表示加载了3张pvr图片

第一张是 PVRTC4,第二、三张是 RGBA4444。


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值