aboutsummaryrefslogtreecommitdiff
path: root/engines/glk/picture.cpp
diff options
context:
space:
mode:
authorPaul Gilbert2019-01-05 17:16:42 -0800
committerPaul Gilbert2019-01-05 17:16:42 -0800
commit81541a5f049c4dd8ec10a9c13b163cf478bdc921 (patch)
tree5e2beb823694ddb2c9b3d882d998ac0a0a4b59d9 /engines/glk/picture.cpp
parentbde504281311953bd99db087471b798da39ed143 (diff)
downloadscummvm-rg350-81541a5f049c4dd8ec10a9c13b163cf478bdc921.tar.gz
scummvm-rg350-81541a5f049c4dd8ec10a9c13b163cf478bdc921.tar.bz2
scummvm-rg350-81541a5f049c4dd8ec10a9c13b163cf478bdc921.zip
GLK: FROTZ: Properly handle picture transparency
Diffstat (limited to 'engines/glk/picture.cpp')
-rw-r--r--engines/glk/picture.cpp23
1 files changed, 18 insertions, 5 deletions
diff --git a/engines/glk/picture.cpp b/engines/glk/picture.cpp
index 2cebcb2780..59ee50c835 100644
--- a/engines/glk/picture.cpp
+++ b/engines/glk/picture.cpp
@@ -110,6 +110,7 @@ Picture *Pictures::load(uint32 id) {
const Graphics::Surface *img;
const byte *palette = nullptr;
uint palCount = 0;
+ int transColor = -1;
Picture *pic;
// Check if the picture is already in the store
@@ -131,6 +132,7 @@ Picture *Pictures::load(uint32 id) {
img = raw.getSurface();
palette = raw.getPalette();
palCount = raw.getPaletteColorCount();
+ transColor = raw.getTransparentColor();
} else if (f.open(Common::String::format("pic%u.rect", id))) {
rectImg.w = f.readUint16LE();
rectImg.h = f.readUint16LE();
@@ -144,6 +146,8 @@ Picture *Pictures::load(uint32 id) {
pic->_refCount = 1;
pic->_id = id;
pic->_scaled = false;
+ if (transColor != -1)
+ pic->clear(pic->getTransparentColor());
if (!img->getPixels()) {
// Area definition without any content
@@ -158,11 +162,13 @@ Picture *Pictures::load(uint32 id) {
const byte *srcP = (const byte *)img->getPixels();
byte *destP = (byte *)pic->getPixels();
for (int idx = 0; idx < img->w * img->h; ++idx, srcP++, destP += pic->format.bytesPerPixel) {
- uint val = (*srcP >= palCount) ? 0 : pal[*srcP];
- if (pic->format.bytesPerPixel == 2)
- WRITE_LE_UINT16(destP, val);
- else
- WRITE_LE_UINT32(destP, val);
+ if ((int)*srcP != transColor) {
+ uint val = (*srcP >= palCount) ? 0 : pal[*srcP];
+ if (pic->format.bytesPerPixel == 2)
+ WRITE_LE_UINT16(destP, val);
+ else
+ WRITE_LE_UINT32(destP, val);
+ }
}
}
@@ -188,6 +194,13 @@ Picture *Pictures::scale(Picture *src, size_t sx, size_t sy) {
/*--------------------------------------------------------------------------*/
+Picture::Picture(int width, int height, const Graphics::PixelFormat &fmt) :
+ Graphics::ManagedSurface(width, height, fmt), _refCount(0), _id(0), _scaled(false) {
+
+ // Default transparent color chosen at random
+ _transColor = format.RGBToColor(0x77, 0x77, 0x77);
+}
+
void Picture::increment() {
++_refCount;
}