Add a debug function to our intermediate PVRTC images

This commit is contained in:
Pavel Krajcevski 2013-09-06 01:57:06 -04:00
parent 0d0c65f536
commit 92827c23fc
2 changed files with 26 additions and 0 deletions

View file

@ -57,6 +57,9 @@
#include "Pixel.h"
#include "Core/include/Image.h"
#include "IO/include/ImageFile.h"
namespace PVRTCC {
Image::Image(uint32 height, uint32 width)
@ -231,4 +234,25 @@ const Pixel & Image::operator()(uint32 i, uint32 j) const {
return m_Pixels[j * m_Width + i];
}
void Image::DebugOutput(const char *filename) const {
uint32 *outPixels = new uint32[m_Width * m_Height];
const uint8 fullDepth[4] = { 8, 8, 8, 8 };
for(int j = 0; j < m_Height; j++) {
for(int i = 0; i < m_Width; i++) {
uint32 idx = j * m_Width + i;
Pixel p = m_Pixels[idx];
p.ChangeBitDepth(fullDepth);
outPixels[idx] = p.PackRGBA();
}
}
::Image img(m_Height, m_Width, outPixels);
char debugFilename[256];
sprintf(debugFilename, "%s.png", filename);
::ImageFile imgFile(debugFilename, eFileFormat_PNG, img);
imgFile.Write();
}
} // namespace PVRTCC

View file

@ -77,6 +77,8 @@ class Image {
uint32 GetWidth() const { return m_Width; }
uint32 GetHeight() const { return m_Height; }
void DebugOutput(const char *filename) const;
private:
uint32 m_Width;
uint32 m_Height;