From e609075d04b117c90194d09a757efe782c73c1a0 Mon Sep 17 00:00:00 2001 From: Pavel Krajcevski Date: Wed, 18 Sep 2013 18:03:08 -0400 Subject: [PATCH] Split apart the index calculation and pixel lookup functions --- PVRTCEncoder/src/Image.cpp | 6 +++++- PVRTCEncoder/src/Image.h | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/PVRTCEncoder/src/Image.cpp b/PVRTCEncoder/src/Image.cpp index cbca9d3..1cc997f 100644 --- a/PVRTCEncoder/src/Image.cpp +++ b/PVRTCEncoder/src/Image.cpp @@ -252,7 +252,11 @@ void Image::ExpandTo8888() { } } -const Pixel &Image::GetPixel(int32 i, int32 j, EWrapMode wrapMode) { +const Pixel &Image::GetPixel(int32 i, int32 j, EWrapMode wrapMode) const { + return m_Pixels[GetPixelIndex(i, j, wrapMode)]; +} + +const uint32 Image::GetPixelIndex(int32 i, int32 j, EWrapMode wrapMode) const { while(i < 0) { if(wrapMode == eWrapMode_Clamp) { i = 0; diff --git a/PVRTCEncoder/src/Image.h b/PVRTCEncoder/src/Image.h index 8550d2a..e7b35e6 100644 --- a/PVRTCEncoder/src/Image.h +++ b/PVRTCEncoder/src/Image.h @@ -87,7 +87,8 @@ class Image { Pixel *m_Pixels; Pixel *m_FractionalPixels; - const Pixel &GetPixel(int32 i, int32 j, EWrapMode wrapMode = eWrapMode_Clamp); + const uint32 GetPixelIndex(int32 i, int32 j, EWrapMode wrapMode = eWrapMode_Clamp) const; + const Pixel &GetPixel(int32 i, int32 j, EWrapMode wrapMode = eWrapMode_Clamp) const; }; } // namespace PVRTCC