diff --git a/ASTCEncoder/src/Decompressor.cpp b/ASTCEncoder/src/Decompressor.cpp index dde3e8f..c0d9b75 100644 --- a/ASTCEncoder/src/Decompressor.cpp +++ b/ASTCEncoder/src/Decompressor.cpp @@ -605,7 +605,8 @@ namespace ASTCC { uint32 Ds = (1024 + (blockWidth/2)) / (blockWidth - 1); uint32 Dt = (1024 + (blockHeight/2)) / (blockHeight - 1); - for(uint32 plane = 0; plane < (params.m_bDualPlane? 2U : 1U); plane++) + const uint32 kPlaneScale = params.m_bDualPlane? 2U : 1U; + for(uint32 plane = 0; plane < kPlaneScale; plane++) for(uint32 t = 0; t < blockHeight; t++) for(uint32 s = 0; s < blockWidth; s++) { uint32 cs = Ds * s; @@ -630,8 +631,7 @@ namespace ASTCC { #define FIND_TEXEL(tidx, bidx) \ uint32 p##bidx = 0; \ do { \ - if(w##bidx > 0) { \ - assert((tidx) < (params.m_Width * params.m_Height)); \ + if((tidx) < (params.m_Width * params.m_Height)) { \ p##bidx = unquantized[plane][(tidx)]; \ } \ } \ diff --git a/IO/src/ImageLoader.cpp b/IO/src/ImageLoader.cpp index b2b060d..298e260 100644 --- a/IO/src/ImageLoader.cpp +++ b/IO/src/ImageLoader.cpp @@ -157,8 +157,8 @@ bool ImageLoader::LoadFromPixelBuffer(const uint32 *data, bool flipY) { m_BlueData = new uint8[nPixels]; m_AlphaData = new uint8[nPixels]; - for (uint32 i = 0; i < m_Width; i++) { - for (uint32 j = 0; j < m_Height; j++) { + for (uint32 j = 0; j < m_Height; j++) { + for (uint32 i = 0; i < m_Width; i++) { uint32 idx = j*m_Height + i; uint32 pIdx = idx; if(flipY) @@ -186,9 +186,6 @@ FasTC::Image<> *ImageLoader::LoadImage() { if(!ReadData()) return NULL; - m_Width = GetWidth(); - m_Height = GetHeight(); - // Create RGBA buffer const unsigned int dataSz = 4 * GetWidth() * GetHeight(); m_PixelData = new unsigned char[dataSz]; diff --git a/IO/src/ImageLoaderTGA.cpp b/IO/src/ImageLoaderTGA.cpp index 4f0ab09..ccae736 100644 --- a/IO/src/ImageLoaderTGA.cpp +++ b/IO/src/ImageLoaderTGA.cpp @@ -69,7 +69,9 @@ ImageLoaderTGA::~ImageLoaderTGA() { } bool ImageLoaderTGA::ReadData() { Targa tga; - targa_loadFromData(&tga, m_RawData, m_NumRawDataBytes); + if (targa_loadFromData(&tga, m_RawData, m_NumRawDataBytes) < 0) { + return false; + } m_Width = tga.width; m_Height = tga.height;