aboutsummaryrefslogtreecommitdiff
path: root/common/scaler/thumbnail.cpp
diff options
context:
space:
mode:
authorEugene Sandulenko2005-07-30 21:11:48 +0000
committerEugene Sandulenko2005-07-30 21:11:48 +0000
commit6b4484472b79dc7ea7d1ce545a28fba7d3b7696f (patch)
treec44c4e61f18ddd537f7082cb48869cf33d422fbd /common/scaler/thumbnail.cpp
parent86ab70b149e5cd00cf54f2e41896e2c4e16795e4 (diff)
downloadscummvm-rg350-6b4484472b79dc7ea7d1ce545a28fba7d3b7696f.tar.gz
scummvm-rg350-6b4484472b79dc7ea7d1ce545a28fba7d3b7696f.tar.bz2
scummvm-rg350-6b4484472b79dc7ea7d1ce545a28fba7d3b7696f.zip
Remove trailing whitespaces.
svn-id: r18604
Diffstat (limited to 'common/scaler/thumbnail.cpp')
-rw-r--r--common/scaler/thumbnail.cpp52
1 files changed, 26 insertions, 26 deletions
diff --git a/common/scaler/thumbnail.cpp b/common/scaler/thumbnail.cpp
index bdbd5d0104..8ada19a670 100644
--- a/common/scaler/thumbnail.cpp
+++ b/common/scaler/thumbnail.cpp
@@ -31,11 +31,11 @@ template<int bitFormat>
uint16 quadBlockInterpolate(const uint8* src, uint32 srcPitch) {
uint16 colorx1y1 = *(((const uint16*)src));
uint16 colorx2y1 = *(((const uint16*)src) + 1);
-
+
uint16 colorx1y2 = *(((const uint16*)(src + srcPitch)));
uint16 colorx2y2 = *(((const uint16*)(src + srcPitch)) + 1);
-
- return Q_INTERPOLATE<bitFormat>(colorx1y1, colorx2y1, colorx1y2, colorx2y2);
+
+ return Q_INTERPOLATE<bitFormat>(colorx1y1, colorx2y1, colorx1y2, colorx2y2);
}
template<int bitFormat>
@@ -62,7 +62,7 @@ void createThumbnail_4(const uint8* src, uint32 srcPitch, uint8* dstPtr, uint32
uint16 downleft = quadBlockInterpolate<bitFormat>(src + srcPitch * 2 + 2 * x, srcPitch);
uint16 downright = quadBlockInterpolate<bitFormat>(src + srcPitch * 2 + 2 * (x + 2), srcPitch);
- *((uint16*)dstPtr) = Q_INTERPOLATE<bitFormat>(upleft, upright, downleft, downright);
+ *((uint16*)dstPtr) = Q_INTERPOLATE<bitFormat>(upleft, upright, downleft, downright);
}
dstPtr += (dstPitch - 2 * width / 4);
src += 4 * srcPitch;
@@ -73,9 +73,9 @@ void createThumbnail(const uint8* src, uint32 srcPitch, uint8* dstPtr, uint32 ds
// only 1/2 and 1/4 downscale supported
if (width != 320 && width != 640)
return;
-
+
int downScaleMode = (width == 320) ? 2 : 4;
-
+
if (downScaleMode == 2) {
if (gBitFormat == 565)
createThumbnail_2<565>(src, srcPitch, dstPtr, dstPitch, width, height);
@@ -93,74 +93,74 @@ void createThumbnail(const uint8* src, uint32 srcPitch, uint8* dstPtr, uint32 ds
/**
* Copies the current screen contents to a new surface, using RGB565 format.
* WARNING: surf->free() must be called by the user to avoid leaking.
- *
+ *
* @param surf the surfce to store the data in it
*/
static bool grabScreen565(Graphics::Surface *surf) {
Graphics::Surface screen;
if (!g_system->grabRawScreen(&screen))
return false;
-
+
assert(screen.bytesPerPixel == 1 && screen.pixels != 0);
-
+
byte palette[256 * 4];
g_system->grabPalette(&palette[0], 0, 256);
-
+
surf->create(screen.w, screen.h, 2);
-
+
for (uint y = 0; y < screen.h; ++y) {
for (uint x = 0; x < screen.w; ++x) {
byte r, g, b;
r = palette[((uint8*)screen.pixels)[y * screen.pitch + x] * 4];
g = palette[((uint8*)screen.pixels)[y * screen.pitch + x] * 4 + 1];
b = palette[((uint8*)screen.pixels)[y * screen.pitch + x] * 4 + 2];
-
+
((uint16*)surf->pixels)[y * surf->w + x] = (((r >> 3) & 0x1F) << 11) | (((g >> 2) & 0x3F) << 5) | ((b >> 3) & 0x1F);
}
}
-
+
screen.free();
return true;
}
bool createThumbnailFromScreen(Graphics::Surface* surf) {
assert(surf);
-
+
int screenWidth = g_system->getWidth();
int screenHeight = g_system->getHeight();
-
+
Graphics::Surface screen;
if (!grabScreen565(&screen))
return false;
uint16 width = screenWidth;
-
+
if (screenWidth < 320) {
// Special case to handle MM NES (uses a screen width of 256)
width = 320;
-
+
// center MM NES screen
Graphics::Surface newscreen;
newscreen.create(width, screen.h, screen.bytesPerPixel);
-
+
uint8 *dst = (uint8*)newscreen.getBasePtr((320 - screenWidth) / 2, 0);
uint8 *src = (uint8*)screen.getBasePtr(0, 0);
uint16 height = screen.h;
-
+
while (height--) {
memcpy(dst, src, screen.pitch);
dst += newscreen.pitch;
src += screen.pitch;
}
-
+
screen.free();
screen = newscreen;
} else if (screenWidth == 720) {
// Special case to handle Hercules mode
width = 640;
screenHeight = 400;
-
+
// cut off menu and so on..
Graphics::Surface newscreen;
newscreen.create(width, 400, screen.bytesPerPixel);
@@ -177,16 +177,16 @@ bool createThumbnailFromScreen(Graphics::Surface* surf) {
screen.free();
screen = newscreen;
}
-
+
uint16 newHeight = !(screenHeight % 240) ? kThumbnailHeight2 : kThumbnailHeight1;
-
+
int gBitFormatBackUp = gBitFormat;
gBitFormat = 565;
surf->create(kThumbnailWidth, newHeight, sizeof(uint16));
- createThumbnail((const uint8*)screen.pixels, width * sizeof(uint16), (uint8*)surf->pixels, surf->pitch, width, screenHeight);
+ createThumbnail((const uint8*)screen.pixels, width * sizeof(uint16), (uint8*)surf->pixels, surf->pitch, width, screenHeight);
gBitFormat = gBitFormatBackUp;
-
+
screen.free();
-
+
return true;
}