diff options
author | Matthew Stewart | 2018-07-17 04:10:48 -0400 |
---|---|---|
committer | Eugene Sandulenko | 2018-08-09 08:37:30 +0200 |
commit | 52cfe602712ad39174379d56e1b45b7121fefda6 (patch) | |
tree | 32f9a3fca6f557c930afa3dd93bb93c1b306219a /engines/startrek/bitmap.cpp | |
parent | b9eca08db639299cfa13385db45b84b0b01cda28 (diff) | |
download | scummvm-rg350-52cfe602712ad39174379d56e1b45b7121fefda6.tar.gz scummvm-rg350-52cfe602712ad39174379d56e1b45b7121fefda6.tar.bz2 scummvm-rg350-52cfe602712ad39174379d56e1b45b7121fefda6.zip |
STARTREK: Get starfields working for the intro
Diffstat (limited to 'engines/startrek/bitmap.cpp')
-rw-r--r-- | engines/startrek/bitmap.cpp | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/engines/startrek/bitmap.cpp b/engines/startrek/bitmap.cpp index 19f1434388..2e6eb78d92 100644 --- a/engines/startrek/bitmap.cpp +++ b/engines/startrek/bitmap.cpp @@ -30,8 +30,19 @@ Bitmap::Bitmap(SharedPtr<FileStream> stream) { width = stream->readUint16(); height = stream->readUint16(); - pixels = new byte[width*height]; - stream->read(pixels, width*height); + pixelsArraySize = width * height; + pixels = new byte[pixelsArraySize]; + stream->read(pixels, width * height); +} + +Bitmap::Bitmap(const Bitmap &bitmap) { + xoffset = bitmap.xoffset; + yoffset = bitmap.yoffset; + width = bitmap.width; + height = bitmap.height; + pixelsArraySize = bitmap.pixelsArraySize; + pixels = new byte[pixelsArraySize]; + memcpy(pixels, bitmap.pixels, pixelsArraySize); } Bitmap::Bitmap(int w, int h) : width(w), height(h), xoffset(0), yoffset(0) { @@ -39,7 +50,8 @@ Bitmap::Bitmap(int w, int h) : width(w), height(h), xoffset(0), yoffset(0) { } Bitmap::~Bitmap() { - delete[] pixels; + if (pixels != nullptr) + delete[] pixels; } @@ -49,7 +61,14 @@ TextBitmap::TextBitmap(int w, int h) { // Width and Height are the total dimensions. Since each character takes 8 pixels in // each dimension, the "pixels" array (which actually stores character indices) must // be smaller. - pixels = new byte[width/8*height/8]; + pixelsArraySize = width / 8 * height / 8; + pixels = new byte[pixelsArraySize]; +} + +StubBitmap::StubBitmap(int w, int h) { + width = w; + height = h; + pixelsArraySize = 0; } } |