Hang up at constructing of CPVRTexture(CPVRTextureHeader& sHeader, void* pData)

I try to make RGB8888-format image to PVRTC4bit-format image.

Then, I prepared the "PVRTextureHeaderV3" and the data of RGB8888-format image,

and converted it by CPVRTCTexture(CPVRTextureHeader& sHeader, void* pData).

But, when constructoring of CPVRTCTexture, the program hung up.

The odd thing is that there are some conditions of hangup as below.

1. VStudio-Debug Mode && MipMapLevel = more than 1(only 1 is OK) && ImageWidth or Height = 512 and more(256 and less is OK)

2. VStudio-Release Mode(I don't know if any other condition is involved)

I wait for some advises.


For reference, I write the source code and the environment.

SDK : OpenglES v2.10 for windows x86 emulation, PC:Windows XP 32bit (memory is enough)

IDE : Visual Studio 2008(using MFC)

Source Code:

unsigned char* l_pImageData[WIDTH*HEIGHT*4]; //pixel values are set

//Making of Header

 PVRTextureHeaderV3 l_cHeader;

 l_cHeader.u32Version = PVRTEX3_IDENT;    //Version

 l_cHeader.u32Flags = PVRTEX3_PREMULTIPLIED;   //Flags

 l_cHeader.u64PixelFormat = PVRStandard8PixelType.PixelTypeID; //PixelFormat

 l_cHeader.u32ColourSpace = ePVRTCSpacelRGB;   //ColourSpace

 l_cHeader.u32ChannelType = ePVRTVarTypeUnsignedByteNorm; //ChannelType

 l_cHeader.u32Height = HEIGHT;     //Height

 l_cHeader.u32Width = WIDTH;      //Width

 l_cHeader.u32Depth = 1;        //Depth

 l_cHeader.u32NumSurfaces = 1;      //NumSurfaces

 l_cHeader.u32NumFaces = 1;       //NumFaces

 l_cHeader.u32MIPMapCount = 2;      //MipMapCount

 l_cHeader.u32MetaDataSize = 0;      //MetaDataSize

 //Create Texture

 CPVRTexture l_cOrgTexture(l_cHeader, l_pImageData); <--[hang-up step]

Hi Yoshihiro,

The reason you get a hang when you’re constructing the data with anything other than one MIP-Map is because the value passed in here tells the constructor how much memory to allocate/copy. When you pass in your data, it tries to copy enough data to fill all your MIP-Map levels. Since you’ve only allocated enough for the top level, it will cause an exception when attempting to copy the second MIP-Map.

If you’re just trying to allocate the space, you should simply pass in NULL rather than a pointer, as the constructor will allocate enough data for you.

If you’re copying in actual image data, you should set the properties to that of the image data you pass in (so if your image has one MIP-Map, just set it to one MIP-Map). To generate MIP Maps you should call pvrtexture::GenerateMIPMaps() with appropriate arguments.

I hope that helps?


Hi Tobias,

Thank you for your quick reply!!

I tried to make the all MipMaps with referring to your advise, and I could do it normally!!

I appreciate your assistance.



I'd like to get the size of the created PVRTC data.

So I save the data to a pvr file with saveFile(), and measure the file size....(it's not a big problem)

Is there any other efficient way to get the size.....mm

Hi Yoshihiro,

Apologies, I missed your question at the bottom of this post last time I looked. There is an alternative way, adding the values of:

CPVRTextureHeader::getDataSize() + CPVRTextureHeader::getMetaDataSize() + PVRTEX3_HEADERSIZE

will give you the full file size for any data type.