aboutsummaryrefslogtreecommitdiff
path: root/graphics
diff options
context:
space:
mode:
Diffstat (limited to 'graphics')
-rw-r--r--graphics/thumbnail.cpp28
-rw-r--r--graphics/thumbnail.h2
2 files changed, 17 insertions, 13 deletions
diff --git a/graphics/thumbnail.cpp b/graphics/thumbnail.cpp
index a3037e5ad5..72a06f91ec 100644
--- a/graphics/thumbnail.cpp
+++ b/graphics/thumbnail.cpp
@@ -147,7 +147,11 @@ bool skipThumbnail(Common::SeekableReadStream &in) {
return true;
}
-Graphics::Surface *loadThumbnail(Common::SeekableReadStream &in) {
+bool loadThumbnail(Common::SeekableReadStream &in, Graphics::Surface *&thumbnail, bool skipThumbnail) {
+ if (skipThumbnail) {
+ return Graphics::skipThumbnail(in);
+ }
+
const uint32 position = in.pos();
ThumbnailHeader header;
HeaderState headerState = loadHeader(in, header, true);
@@ -160,32 +164,32 @@ Graphics::Surface *loadThumbnail(Common::SeekableReadStream &in) {
// stream at this point then.
if (headerState == kHeaderNone) {
in.seek(position, SEEK_SET);
- return 0;
+ return false;
} else if (headerState == kHeaderUnsupported) {
in.seek(header.size - (in.pos() - position), SEEK_CUR);
- return 0;
+ return false;
}
if (header.format.bytesPerPixel != 2 && header.format.bytesPerPixel != 4) {
warning("trying to load thumbnail with unsupported bit depth %d", header.format.bytesPerPixel);
- return 0;
+ return false;
}
- Graphics::Surface *const to = new Graphics::Surface();
- to->create(header.width, header.height, header.format);
+ thumbnail = new Graphics::Surface();
+ thumbnail->create(header.width, header.height, header.format);
- for (int y = 0; y < to->h; ++y) {
+ for (int y = 0; y < thumbnail->h; ++y) {
switch (header.format.bytesPerPixel) {
case 2: {
- uint16 *pixels = (uint16 *)to->getBasePtr(0, y);
- for (uint x = 0; x < to->w; ++x) {
+ uint16 *pixels = (uint16 *)thumbnail->getBasePtr(0, y);
+ for (uint x = 0; x < thumbnail->w; ++x) {
*pixels++ = in.readUint16BE();
}
} break;
case 4: {
- uint32 *pixels = (uint32 *)to->getBasePtr(0, y);
- for (uint x = 0; x < to->w; ++x) {
+ uint32 *pixels = (uint32 *)thumbnail->getBasePtr(0, y);
+ for (uint x = 0; x < thumbnail->w; ++x) {
*pixels++ = in.readUint32BE();
}
} break;
@@ -194,7 +198,7 @@ Graphics::Surface *loadThumbnail(Common::SeekableReadStream &in) {
assert(0);
}
}
- return to;
+ return true;
}
bool saveThumbnail(Common::WriteStream &out) {
diff --git a/graphics/thumbnail.h b/graphics/thumbnail.h
index cec3d02800..17ce856e23 100644
--- a/graphics/thumbnail.h
+++ b/graphics/thumbnail.h
@@ -52,7 +52,7 @@ bool skipThumbnail(Common::SeekableReadStream &in);
/**
* Loads a thumbnail from the given input stream.
*/
-Graphics::Surface *loadThumbnail(Common::SeekableReadStream &in);
+bool loadThumbnail(Common::SeekableReadStream &in, Graphics::Surface *&thumbnail, bool skipThumbnail = false);
/**
* Saves a thumbnail to the given write stream.