From 1d25e31d2a479dd1eb5da303cfd0610dfe4d6511 Mon Sep 17 00:00:00 2001 From: Pavel Krajcevski Date: Sat, 31 Aug 2013 18:30:47 -0400 Subject: [PATCH] Bilinear upscale bug fixes. --- PVRTCEncoder/src/Image.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/PVRTCEncoder/src/Image.cpp b/PVRTCEncoder/src/Image.cpp index 66002f5..60beac4 100644 --- a/PVRTCEncoder/src/Image.cpp +++ b/PVRTCEncoder/src/Image.cpp @@ -115,28 +115,28 @@ void Image::BilinearUpscale(uint32 times, EWrapMode wrapMode) { int32 highYIdx = (j + offset) / scale; int32 lowYIdx = highYIdx - 1; - uint32 lowXWeight = (i + offset) % scale; - uint32 highXWeight = scale - lowXWeight; - uint32 lowYWeight = (j + offset) % scale; - uint32 highYWeight = scale - lowYWeight; + uint32 highXWeight = (i + offset) % scale; + uint32 lowXWeight = scale - highXWeight; + uint32 highYWeight = (j + offset) % scale; + uint32 lowYWeight = scale - highYWeight; - const Pixel &topLeft = GetPixel(highXIdx, lowYIdx, wrapMode); - const Pixel &topRight = GetPixel(lowXIdx, lowYIdx, wrapMode); - const Pixel &bottomLeft = GetPixel(highXIdx, highYIdx, wrapMode); - const Pixel &bottomRight = GetPixel(lowXIdx, highYIdx, wrapMode); + const Pixel &topLeft = GetPixel(lowXIdx, lowYIdx, wrapMode); + const Pixel &topRight = GetPixel(highXIdx, lowYIdx, wrapMode); + const Pixel &bottomLeft = GetPixel(lowXIdx, highYIdx, wrapMode); + const Pixel &bottomRight = GetPixel(highXIdx, highYIdx, wrapMode); // bilerp each channel.... for(uint32 c = 0; c < 4; c++) { const uint16 left = (lowYWeight * static_cast(topLeft.Component(c)) + highYWeight * static_cast(bottomLeft.Component(c))) - >> scale; + / scale; const uint16 right = (lowYWeight * static_cast(topRight.Component(c)) + highYWeight * static_cast(bottomRight.Component(c))) - >> scale; + / scale; - p.Component(c) = (left * lowXWeight + right * highXWeight) >> scale; + p.Component(c) = (left * lowXWeight + right * highXWeight) / scale; } } }