From 072b74f7b32a69ac37de30fd5f9dcb42fe9eee98 Mon Sep 17 00:00:00 2001 From: Pavel Krajcevski Date: Wed, 5 Nov 2014 18:04:40 -0500 Subject: [PATCH] Flatten indices properly --- IO/src/ImageLoader.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/IO/src/ImageLoader.cpp b/IO/src/ImageLoader.cpp index 298e260..5349263 100644 --- a/IO/src/ImageLoader.cpp +++ b/IO/src/ImageLoader.cpp @@ -159,10 +159,10 @@ bool ImageLoader::LoadFromPixelBuffer(const uint32 *data, bool flipY) { for (uint32 j = 0; j < m_Height; j++) { for (uint32 i = 0; i < m_Width; i++) { - uint32 idx = j*m_Height + i; + uint32 idx = j*m_Width + i; uint32 pIdx = idx; if(flipY) - idx = (m_Height - j - 1)*m_Height + i; + idx = (m_Height - j - 1)*m_Width + i; uint32 pixel = data[idx]; m_RedData[pIdx] = static_cast(pixel & 0xFF); m_GreenData[pIdx] = static_cast((pixel >> 8) & 0xFF);