diff options
author | Eugene Sandulenko | 2013-08-17 20:08:00 +0300 |
---|---|---|
committer | Eugene Sandulenko | 2013-09-06 14:51:15 +0300 |
commit | 6a172694fb5da9851447eaf30403e63ed032b98b (patch) | |
tree | 8a33c900a663389556501a5aec8e692581241dc6 /engines | |
parent | 4db508bec199666d5287889ca24656bf0705a4f2 (diff) | |
download | scummvm-rg350-6a172694fb5da9851447eaf30403e63ed032b98b.tar.gz scummvm-rg350-6a172694fb5da9851447eaf30403e63ed032b98b.tar.bz2 scummvm-rg350-6a172694fb5da9851447eaf30403e63ed032b98b.zip |
FULLPIPE: Implement Bitmap::reverseImage()
Diffstat (limited to 'engines')
-rw-r--r-- | engines/fullpipe/gfx.cpp | 91 | ||||
-rw-r--r-- | engines/fullpipe/gfx.h | 8 |
2 files changed, 95 insertions, 4 deletions
diff --git a/engines/fullpipe/gfx.cpp b/engines/fullpipe/gfx.cpp index 9c19762d45..9b15d695f0 100644 --- a/engines/fullpipe/gfx.cpp +++ b/engines/fullpipe/gfx.cpp @@ -31,6 +31,28 @@ namespace Fullpipe { +Bitmap::Bitmap() { + _x = 0; + _y = 0; + _width = 0; + _height = 0; + _pixels = 0; + _type = 0; + _dataSize = 0; + _flags = 0; +} + +Bitmap::Bitmap(Bitmap *src) { + _x = src->_x; + _y = src->_y; + _flags = src->_flags; + _dataSize = src->_dataSize; + _type = src->_type; + _width = src->_width; + _height = src->_height; + _pixels = src->_pixels; +} + void Bitmap::load(Common::ReadStream *s) { debug(5, "Bitmap::load()"); @@ -40,10 +62,10 @@ void Bitmap::load(Common::ReadStream *s) { _height = s->readUint32LE(); s->readUint32LE(); // pixels _type = s->readUint32LE(); - _field_18 = s->readUint32LE(); + _dataSize = s->readUint32LE(); _flags = s->readUint32LE(); - debug(8, "Bitmap: x: %d y: %d w: %d h: %d field_18: 0x%x", _x, _y, _width, _height, _field_18); + debug(8, "Bitmap: x: %d y: %d w: %d h: %d dataSize: 0x%x", _x, _y, _width, _height, _dataSize); debug(8, "Bitmap: type: %s (0x%04x) flags: 0x%x", Common::tag2string(_type).c_str(), _type, _flags); } @@ -565,6 +587,7 @@ void Bitmap::putDibRB(int32 *palette) { starty = 0; y = endy; + srcPtr = (uint16 *)_pixels; bool breakup = false; @@ -606,6 +629,7 @@ void Bitmap::putDibRB(int32 *palette) { if (x <= 799 + 1 || (fillLen += 799 - x + 1, fillLen > 0)) { if (y <= endy) { curDestPtr = (uint16 *)g_fullpipe->_backgroundSurface.getBasePtr(start1, y); + int bgcolor = palette[(pixel >> 8) & 0xff]; colorFill(curDestPtr, fillLen, bgcolor); } @@ -800,7 +824,68 @@ void Bitmap::copier(uint16 *dest, byte *src, int len, int32 *palette, bool cb05_ } Bitmap *Bitmap::reverseImage() { - warning("STUB: Bitmap::reverseImage()"); + switch (_type) { + case MKTAG('R', 'B', '\0', '\0'): + return reverseImageRB(); + case MKTAG('C', 'B', '\0', '\0'): + return reverseImageCB(); + case MKTAG('C', 'B', '\05', 'e'): + return reverseImageCB05(); + default: + error("Bitmap::reverseImage: Unknown image type: %x", _type); + } + + return 0; +} + +Bitmap *Bitmap::reverseImageRB() { + uint16 *newpixels = (uint16 *)calloc(((_dataSize + 15) & 0xfffffff0) + sizeof(Bitmap), 1); + uint16 *srcPtr = (uint16 *)_pixels; + + int idx = 0; + while (srcPtr[idx] != 0x100) { + uint16 *srcPtr2 = &srcPtr[idx]; + + int prevIdx = idx; + int i = idx; + + while (*srcPtr2) { + ++srcPtr2; + ++idx; + } + + int idx2 = idx; + + newpixels[idx] = srcPtr[idx]; + + while (i != idx) { + int fillLen = 2 - ((srcPtr[prevIdx] & 0xff) != 0 ? 1 : 0); + idx2 -= fillLen; + memcpy(&newpixels[idx2], &srcPtr[prevIdx], 2 * fillLen); + prevIdx = fillLen + i; + i += fillLen; + } + ++idx; + } + newpixels[idx] = 256; + + int oldBmp = ((_dataSize + 15) >> 1) & 0x7FFFFFF8; + memcpy(&newpixels[oldBmp], &srcPtr[oldBmp], sizeof(Bitmap)); + + Bitmap *res = new Bitmap(this); + res->_pixels = (byte *)newpixels; + + return res; +} + +Bitmap *Bitmap::reverseImageCB() { + warning("STUB: Bitmap::reverseImageCB()"); + + return this; +} + +Bitmap *Bitmap::reverseImageCB05() { + warning("STUB: Bitmap::reverseImageCB05()"); return this; } diff --git a/engines/fullpipe/gfx.h b/engines/fullpipe/gfx.h index 7cc18adc7a..eeff02646e 100644 --- a/engines/fullpipe/gfx.h +++ b/engines/fullpipe/gfx.h @@ -38,9 +38,12 @@ struct Bitmap { int _height; byte *_pixels; int _type; - int _field_18; + int _dataSize; int _flags; + Bitmap(); + Bitmap(Bitmap *src); + void load(Common::ReadStream *s); void putDib(int x, int y, int32 *palette); void putDibRB(int32 *palette); @@ -52,6 +55,9 @@ struct Bitmap { void copier(uint16 *dest, byte *src, int len, int32 *palette, bool cb05_format); Bitmap *reverseImage(); + Bitmap *reverseImageRB(); + Bitmap *reverseImageCB(); + Bitmap *reverseImageCB05(); Bitmap *flipVertical(); void drawShaded(int type, int x, int y, byte *palette); |