diff options
author | Eugene Sandulenko | 2015-12-18 11:26:33 +0100 |
---|---|---|
committer | Eugene Sandulenko | 2015-12-27 15:40:53 +0100 |
commit | c00bd70f02f3523930dbe5072575b04eff37dd4d (patch) | |
tree | edd3bc1be7badbe2f5fbd9599378d6f3b79b95ae /engines | |
parent | e112ffdf4885096a3f786cec12612ab9510f7193 (diff) | |
download | scummvm-rg350-c00bd70f02f3523930dbe5072575b04eff37dd4d.tar.gz scummvm-rg350-c00bd70f02f3523930dbe5072575b04eff37dd4d.tar.bz2 scummvm-rg350-c00bd70f02f3523930dbe5072575b04eff37dd4d.zip |
WAGE: Implement drawBitmap
Diffstat (limited to 'engines')
-rw-r--r-- | engines/wage/design.cpp | 64 | ||||
-rw-r--r-- | engines/wage/design.h | 2 |
2 files changed, 64 insertions, 2 deletions
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp index 40a64caed6..31835f88d6 100644 --- a/engines/wage/design.cpp +++ b/engines/wage/design.cpp @@ -92,11 +92,9 @@ void Design::paint(Graphics::Surface *canvas, Patterns &patterns, bool mask) { case 20: drawPolygon(canvas, in, mask, patterns, fillType, borderThickness, borderFillType); break; -/* case 24: drawBitmap(canvas, in, mask); break; -*/ default: warning("Unknown type => %d", type); while (true) { @@ -230,6 +228,68 @@ void Design::drawPolygon(Graphics::Surface *surface, Common::ReadStream &in, boo free(ypoints); } +void Design::drawBitmap(Graphics::Surface *surface, Common::ReadStream &in, bool mask) { + int numBytes = in.readSint16BE(); + int y1 = in.readSint16BE(); + int x1 = in.readSint16BE(); + int y2 = in.readSint16BE(); + int x2 = in.readSint16BE(); + int w = x2 - x1; + int h = y2 - y1; + + numBytes -= 10; + + int x = 0, y = 0; + while (numBytes) { + int n = in.readSByte(); + int count; + int b; + int state; + + numBytes--; + + if ((n >= 0) && (n <= 127)) { // If n is between 0 and 127 inclusive, copy the next n+1 bytes literally. + count = n + 1; + state = 1; + } else if ((n >= -127) && (n <= -1)) { // Else if n is between -127 and -1 inclusive, copy the next byte -n+1 times. + b = in.readByte(); + numBytes--; + count = -n + 1; + state = 2; + } else { // Else if n is -128, noop. + count = 0; + } + + for (int i = 0; i < count; i++) { + byte color; + if (state == 1) { + color = in.readByte(); + numBytes--; + } else if (state == 2) + color = b; + + for (int c = 0; c < 8; c++) { + if (x1 + x >= 0 && x1 + x < surface->w && y1 + y >= 0 && y1 + y < surface->h) + *((byte *)surface->getBasePtr(x1 + x, y1 + y)) = + (color & (1 << (7 - c % 8))) ? + kColorBlack : kColorWhite; + x++; + if (x == w) { + y++; + + if (y == h) + return; + + x = 0; + break; + } + + } + } + + } +} + void Design::patternThickRect(Graphics::Surface *surface, Patterns &patterns, Common::Rect &outer, Common::Rect &inner, byte borderFillType, byte fillType) { patternRect(surface, patterns, outer, borderFillType); diff --git a/engines/wage/design.h b/engines/wage/design.h index 6fa25be89d..6ae83c77e9 100644 --- a/engines/wage/design.h +++ b/engines/wage/design.h @@ -87,6 +87,8 @@ private: Patterns &patterns, byte fillType, byte borderThickness, byte borderFillType); void drawOval(Graphics::Surface *surface, Common::ReadStream &in, bool mask, Patterns &patterns, byte fillType, byte borderThickness, byte borderFillType); + void drawBitmap(Graphics::Surface *surface, Common::ReadStream &in, bool mask); + void patternThickRect(Graphics::Surface *surface, Patterns &patterns, Common::Rect &outer, Common::Rect &inner, byte borderFillType, byte fillType); |