aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormd52011-04-27 13:43:03 +0300
committermd52011-04-27 13:43:03 +0300
commit99e30284593a58fb95edf35a74b5ba2374b485e3 (patch)
treec81a48e61f9b76571bb1ef2b4a7213a35f1ea1de
parent3ab0a133b3fca2e9e28be9d9d6d6efd3a4c2cb88 (diff)
downloadscummvm-rg350-99e30284593a58fb95edf35a74b5ba2374b485e3.tar.gz
scummvm-rg350-99e30284593a58fb95edf35a74b5ba2374b485e3.tar.bz2
scummvm-rg350-99e30284593a58fb95edf35a74b5ba2374b485e3.zip
PNG: Improved code readability a bit
-rw-r--r--graphics/png.cpp22
1 files changed, 12 insertions, 10 deletions
diff --git a/graphics/png.cpp b/graphics/png.cpp
index b256c87cf5..ed1dd78674 100644
--- a/graphics/png.cpp
+++ b/graphics/png.cpp
@@ -127,13 +127,14 @@ Graphics::Surface *PNG::getSurface(const PixelFormat &format) {
for (uint16 i = 0; i < output->h; i++) {
for (uint16 j = 0; j < output->w; j++) {
- if (format.bytesPerPixel == 2) {
+ if (format.bytesPerPixel == 2) { // 2bpp
+ uint16 *dest = ((uint16 *)output->getBasePtr(j, i));
if (_unfilteredSurface->bytesPerPixel == 1) { // Grayscale
if (_transparentColorSpecified)
a = (src[0] == _transparentColor[0]) ? 0 : 0xFF;
- *((uint16 *)output->getBasePtr(j, i)) = format.ARGBToColor( a, src[0], src[0], src[0]);
+ *dest = format.ARGBToColor( a, src[0], src[0], src[0]);
} else if (_unfilteredSurface->bytesPerPixel == 2) { // Grayscale + alpha
- *((uint16 *)output->getBasePtr(j, i)) = format.ARGBToColor(src[1], src[0], src[0], src[0]);
+ *dest = format.ARGBToColor(src[1], src[0], src[0], src[0]);
} else if (_unfilteredSurface->bytesPerPixel == 3) { // RGB
if (_transparentColorSpecified) {
bool isTransparentColor = (src[0] == _transparentColor[0] &&
@@ -141,17 +142,18 @@ Graphics::Surface *PNG::getSurface(const PixelFormat &format) {
src[2] == _transparentColor[2]);
a = isTransparentColor ? 0 : 0xFF;
}
- *((uint16 *)output->getBasePtr(j, i)) = format.ARGBToColor( a, src[0], src[1], src[2]);
+ *dest = format.ARGBToColor( a, src[0], src[1], src[2]);
} else if (_unfilteredSurface->bytesPerPixel == 4) { // RGBA
- *((uint16 *)output->getBasePtr(j, i)) = format.ARGBToColor(src[3], src[0], src[1], src[2]);
+ *dest = format.ARGBToColor(src[3], src[0], src[1], src[2]);
}
- } else {
+ } else { // 4bpp
+ uint32 *dest = ((uint32 *)output->getBasePtr(j, i));
if (_unfilteredSurface->bytesPerPixel == 1) { // Grayscale
if (_transparentColorSpecified)
a = (src[0] == _transparentColor[0]) ? 0 : 0xFF;
- *((uint32 *)output->getBasePtr(j, i)) = format.ARGBToColor( a, src[0], src[0], src[0]);
+ *dest = format.ARGBToColor( a, src[0], src[0], src[0]);
} else if (_unfilteredSurface->bytesPerPixel == 2) { // Grayscale + alpha
- *((uint32 *)output->getBasePtr(j, i)) = format.ARGBToColor(src[1], src[0], src[0], src[0]);
+ *dest = format.ARGBToColor(src[1], src[0], src[0], src[0]);
} else if (_unfilteredSurface->bytesPerPixel == 3) { // RGB
if (_transparentColorSpecified) {
bool isTransparentColor = (src[0] == _transparentColor[0] &&
@@ -159,9 +161,9 @@ Graphics::Surface *PNG::getSurface(const PixelFormat &format) {
src[2] == _transparentColor[2]);
a = isTransparentColor ? 0 : 0xFF;
}
- *((uint32 *)output->getBasePtr(j, i)) = format.ARGBToColor( a, src[0], src[1], src[2]);
+ *dest = format.ARGBToColor( a, src[0], src[1], src[2]);
} else if (_unfilteredSurface->bytesPerPixel == 4) { // RGBA
- *((uint32 *)output->getBasePtr(j, i)) = format.ARGBToColor(src[3], src[0], src[1], src[2]);
+ *dest = format.ARGBToColor(src[3], src[0], src[1], src[2]);
}
}