aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2014-01-14 23:19:24 -0500
committerPaul Gilbert2014-01-14 23:19:24 -0500
commit0985cc51c259aa81ad8583b1dda82e071d7f367b (patch)
treeae89f298b50c2abb171b2119958f3cf5bf8f4ffd
parent5774ce53df3d6603416cb31bdb570ce19ae9d9b4 (diff)
downloadscummvm-rg350-0985cc51c259aa81ad8583b1dda82e071d7f367b.tar.gz
scummvm-rg350-0985cc51c259aa81ad8583b1dda82e071d7f367b.tar.bz2
scummvm-rg350-0985cc51c259aa81ad8583b1dda82e071d7f367b.zip
VOYEUR: Implement pictures with horizontal or vertical flip
-rw-r--r--engines/voyeur/files.cpp37
-rw-r--r--engines/voyeur/files.h12
2 files changed, 46 insertions, 3 deletions
diff --git a/engines/voyeur/files.cpp b/engines/voyeur/files.cpp
index 4c0ae1b4f2..02cdda0f5b 100644
--- a/engines/voyeur/files.cpp
+++ b/engines/voyeur/files.cpp
@@ -742,8 +742,17 @@ PictureResource::PictureResource(BoltFilesState &state, const byte *src) {
int nbytes = _bounds.width() * _bounds.height();
if (_flags & PICFLAG_20) {
- if (_flags & (PICFLAG_80 | PICFLAG_40)) {
- error("TODO: sInitPic - Case 40 | 80");
+ if (_flags & (PICFLAG_VFLIP | PICFLAG_HFLIP)) {
+ // Get the raw data for the picture from another resource
+ uint32 id = READ_LE_UINT32(&src[18]);
+ const byte *srcData = state._curLibPtr->boltEntry(id)._data;
+ _imgData = new byte[nbytes];
+
+ // Flip the image data either horizontally or vertically
+ if (_flags & PICFLAG_HFLIP)
+ flipHorizontal(srcData);
+ else
+ flipVertical(srcData);
} else {
error("TODO: sInitPic - Case !(40 | 80)");
}
@@ -861,6 +870,30 @@ PictureResource::~PictureResource() {
delete[] _imgData;
}
+void PictureResource::flipHorizontal(const byte *data) {
+ const byte *srcP = data + 18;
+ byte *destP = _imgData + _bounds.width() - 1;
+
+ for (int y = 0; y < _bounds.height(); ++y) {
+ for (int x = 0; x < _bounds.width(); ++x, ++srcP, --destP)
+ *destP = *srcP;
+
+ srcP += _bounds.width();
+ destP += _bounds.width();
+ }
+}
+
+void PictureResource::flipVertical(const byte *data) {
+ const byte *srcP = data + 18;
+ byte *destP = _imgData + _bounds.width() * (_bounds.height() - 1);
+
+ for (int y = 0; y < _bounds.height(); ++y) {
+ Common::copy(srcP, srcP + _bounds.width(), destP);
+ srcP += _bounds.width();
+ destP -= _bounds.width();
+ }
+}
+
/*------------------------------------------------------------------------*/
ViewPortResource::ViewPortResource(BoltFilesState &state, const byte *src):
diff --git a/engines/voyeur/files.h b/engines/voyeur/files.h
index 6fc7ad7d0b..105eba51cb 100644
--- a/engines/voyeur/files.h
+++ b/engines/voyeur/files.h
@@ -255,9 +255,19 @@ public:
/* bvoy.blt resource types */
enum PictureFlag { PICFLAG_8 = 8, PICFLAG_10 = 0x10, PICFLAG_20 = 0x20,
- PICFLAG_40 = 0x40, PICFLAG_80 = 0x80, PICFLAG_1000 = 0x1000 };
+ PICFLAG_HFLIP = 0x40, PICFLAG_VFLIP = 0x80, PICFLAG_1000 = 0x1000 };
class PictureResource: public DisplayResource {
+private:
+ /**
+ * Flip the image data horizontally
+ */
+ void flipHorizontal(const byte *data);
+
+ /**
+ * Flip the image data vertically
+ */
+ void flipVertical(const byte *data);
public:
byte _select;
byte _pick;