首先下载PVRTexTool,官网下载地址:http://community.imgtec.com/developers/powervr/
1. 通过PVRTexTool将需要压缩的图片转换为ETC1格式编码的PVR文件
2. 解析PVR文件,官网有PVR文件的说明文档,PVR文件由header format、metadata format、texture data三部分组成。
如果是V3版本,可这样定义PVR文件头部格式,记得指定字节对齐的方式,不然在计算纹理数据偏移的时候容易出错(唉,我就掉进这个坑里了的)
typedef unsigned int uint32;
typedef unsigned long long uint64;
#pragma pack(push,1)
typedef struct _ST_PVR_HEAD_V3 {
uint32 u32Version;
uint32 u32Flags;
uint64 u64PixelFormat;
uint32 u32ColourSpace;
uint32 u32ChannelType;
uint32 u32Height;
uint32 u32Width;
uint32 u32Depth;
uint32 u32NumSurfaces;
uint32 u32NumFaces;
uint32 u32MIPMapCount;
uint32 u32MetaDataSize;
}ST_PVR_HEAD_V3;
#pr