title: Reading PVRTC image color information for each pixel
body: <p>How do I read the image color information for each pixel of PVRTC image?</p>
  
  <p>Here is my code extracting the integer arrays</p>
  
  <pre><code>    NSData *data = [[NSData alloc] initWithContentsOfFile:path];
  
   NSMutableArray *_imageData = [[NSMutableArray alloc] initWithCapacity:10];
  
   BOOL success = FALSE;
   PVRTexHeader *header = NULL;
   uint32_t flags, pvrTag;
   uint32_t dataLength = 0, dataOffset = 0, dataSize = 0;
   uint32_t blockSize = 0, widthBlocks = 0, heightBlocks = 0;
   uint32_t width = 0, height = 0, bpp = 4;
   uint8_t *bytes = NULL;
   uint32_t formatFlags;
  
   header = (PVRTexHeader *)[data bytes];
  
   pvrTag = CFSwapInt32LittleToHost(header-&gt;pvrTag);
  
   if (gPVRTexIdentifier[0] != ((pvrTag &gt;&gt;  0) &amp; 0xff) ||
    gPVRTexIdentifier[1] != ((pvrTag &gt;&gt;  8) &amp; 0xff) ||
    gPVRTexIdentifier[2] != ((pvrTag &gt;&gt; 16) &amp; 0xff) ||
    gPVRTexIdentifier[3] != ((pvrTag &gt;&gt; 24) &amp; 0xff))
   {
    return FALSE;
   }
  
   flags = CFSwapInt32LittleToHost(header-&gt;flags);
   formatFlags = flags &amp; PVR_TEXTURE_FLAG_TYPE_MASK;
  
   if (formatFlags == kPVRTextureFlagTypePVRTC_4 || formatFlags == kPVRTextureFlagTypePVRTC_2)
   {
    [_imageData removeAllObjects];
  
    if (formatFlags == kPVRTextureFlagTypePVRTC_4)
     _internalFormat = GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;
    else if (formatFlags == kPVRTextureFlagTypePVRTC_2)
     _internalFormat = GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG;
  
  
    _width = width = CFSwapInt32LittleToHost(header-&gt;width);
    _height = height = CFSwapInt32LittleToHost(header-&gt;height);
  
    if (CFSwapInt32LittleToHost(header-&gt;bitmaskAlpha))
     _hasAlpha = TRUE;
    else
     _hasAlpha = FALSE;
  
    dataLength = CFSwapInt32LittleToHost(header-&gt;dataLength);
  
    bytes = ((uint8_t *)[data bytes]) + sizeof(PVRTexHeader);
  
    // Calculate the data size for each texture level and respect the minimum number of blocks
    while (dataOffset &lt; dataLength)
    {
     if (formatFlags == kPVRTextureFlagTypePVRTC_4)
     {
      blockSize = 4 * 4; // Pixel by pixel block size for 4bpp
      widthBlocks = width / 4;
      heightBlocks = height / 4;
      bpp = 4;
     }
     else
     {
      blockSize = 8 * 4; // Pixel by pixel block size for 2bpp
      widthBlocks = width / 8;
      heightBlocks = height / 4;
      bpp = 2;
     }
  
     // Clamp to minimum number of blocks
     if (widthBlocks &lt; 2)
      widthBlocks = 2;
     if (heightBlocks &lt; 2)
      heightBlocks = 2;
  
     dataSize = widthBlocks * heightBlocks * ((blockSize  * bpp) / 8);
  
     [_imageData addObject:[NSData dataWithBytes:bytes+dataOffset length:dataSize]];
  
                     for (int i=0; i &lt; mipmapCount; i++)
                      {
  
                NSLog(@"width:%d, height:%d",width,height);
  
                data = [[NSData alloc] initWithData:[_imageData objectAtIndex:i]];
                NSLog(@"data length:%d",[data length]);
  </code></pre>
  
  <p>//extracted 20 sample data, but all u could see are large integer number
                   for(int i = 0; i &lt; 20; i++){
                 NSLog(@"data[%d]:%d",i,data[i]);
                   }</p>