Beispiel #1
0
  explicit ImageTester(const char *filename, bool twobpp) {
    pvrtexture::CPVRTexture pvrTex(filename);

    const uint8 *data = static_cast<const uint8 *>(pvrTex.getDataPtr());
    assert(data);

    const pvrtexture::CPVRTextureHeader &hdr = pvrTex.getHeader();
    const uint32 w = hdr.getWidth();
    const uint32 h = hdr.getHeight();

    uint32 *outPixels = new uint32[w * h];

    FasTC::ECompressionFormat fmt = FasTC::eCompressionFormat_PVRTC4;
    if(twobpp) {
      fmt = FasTC::eCompressionFormat_PVRTC2;
    }

    uint8 *outBuf = reinterpret_cast<uint8 *>(outPixels);
    FasTC::DecompressionJob dcj(fmt, data, outBuf, w, h);
#ifdef DEBUG_PVRTC_DECODER
    PVRTCC::Decompress(dcj, PVRTCC::eWrapMode_Wrap, true);
#else
    PVRTCC::Decompress(dcj, PVRTCC::eWrapMode_Wrap);
#endif

    bool result = pvrtexture::Transcode(pvrTex,
                                        pvrtexture::PVRStandard8PixelType,
                                        ePVRTVarTypeUnsignedByte,
                                        ePVRTCSpacelRGB);
    EXPECT_TRUE(result);

    uint32 *libPixels = static_cast<uint32 *>(pvrTex.getDataPtr());

    for(uint32 i = 0; i < w*h; i++) {
      EXPECT_EQ(PixelPrinter(libPixels[i]), PixelPrinter(outPixels[i]));
    }

#ifdef DEBUG_PVRTC_DECODER
    char dbgfname[256];
    snprintf(dbgfname, sizeof(dbgfname), "Debug%s.png", filename);
    ImageFile imgFile(dbgfname, eFileFormat_PNG, FasTC::Image<>(w, h, outPixels));
    imgFile.Write();
#endif  // OUTPUT_DEBUG_IMAGE

    delete outPixels;
  }
Beispiel #2
0
bool ImageLoaderPVR::ReadData() {
  pvrtexture::CPVRTexture pvrTex((const void *)m_RawData);
  if(!pvrtexture::Transcode(pvrTex,
                            pvrtexture::PVRStandard8PixelType,
                            ePVRTVarTypeUnsignedByte,
                            ePVRTCSpacelRGB)) {
    ReportError("Unable to convert PVRTexture... possibly failed to load file");
    return false;
  }

  const pvrtexture::CPVRTextureHeader &hdr = pvrTex.getHeader();

  m_Width = hdr.getWidth();
  m_Height = hdr.getHeight();

  return LoadFromPixelBuffer(reinterpret_cast<uint32 *>(pvrTex.getDataPtr()));
}