FULLPIPE: Bitmap loading

This commit is contained in:
Eugene Sandulenko 2013-07-11 08:09:11 +03:00
parent c2103bb9cd
commit f18e318f78
4 changed files with 73 additions and 5 deletions

View File

@ -24,8 +24,24 @@
#include "fullpipe/objects.h"
#include "common/memstream.h"
namespace Fullpipe {
void Bitmap::load(Common::ReadStream *s) {
x = s->readUint32LE();
y = s->readUint32LE();
width = s->readUint32LE();
height = s->readUint32LE();
s->readUint32LE(); // pixels
type = s->readUint32LE();
field_18 = s->readUint32LE();
flags = s->readUint32LE();
debug(9, "x: %d y: %d w: %d h: %d", x, y, width, height);
debug(9, "type: %d field_18: %d flags: 0x%x", type, field_18, flags);
}
Background::Background() {
_x = 0;
_y = 0;
@ -227,6 +243,27 @@ void Picture::setAOIDs() {
warning("STUB: Picture::setAOIDs()");
}
void Picture::init() {
_bitmap = new Bitmap();
getDibInfo();
_bitmap->flags |= 0x1000000;
}
void Picture::getDibInfo() {
int off = _dataSize & ~0xf;
if (_dataSize != off) {
warning("Uneven data size: 0x%x", _dataSize);
}
Common::MemoryReadStream *s = new Common::MemoryReadStream(_data + off, 32);
_bitmap->load(s);
_bitmap->pixels = _data;
}
BigPicture::BigPicture() {
}

View File

@ -23,12 +23,27 @@
#ifndef FULLPIPE_GFX_H
#define FULLPIPE_GFX_H
class Common::ReadStream;
namespace Fullpipe {
class ShadowsItemArray : public CObArray {
// empty
};
struct Bitmap {
int x;
int y;
int width;
int height;
byte *pixels;
int type;
int field_18;
int flags;
void load(Common::ReadStream *s);
};
class Picture : public MemoryObject {
friend class Movement;
@ -39,7 +54,7 @@ class Picture : public MemoryObject {
int _field_44;
int _width;
int _height;
int _bitmap;
Bitmap *_bitmap;
int _field_54;
MemoryObject2 *_memoryObject2;
int _alpha;
@ -49,6 +64,8 @@ class Picture : public MemoryObject {
Picture();
virtual bool load(MfcArchive &file);
void setAOIDs();
void init();
void getDibInfo();
};
class BigPicture : public Picture {

View File

@ -134,15 +134,27 @@ void MemoryObject::loadFile(char *filename) {
if (s) {
assert(s->size() > 0);
debug(0, "Loading %s", filename);
_data = calloc(s->size(), 1);
s->read(_data, s->size());
_dataSize = s->size();
debug(0, "Loading %s (%d bytes)", filename, _dataSize);
_data = (byte *)calloc(_dataSize, 1);
s->read(_data, _dataSize);
delete s;
}
}
}
void *MemoryObject::getData() {
load();
if (_field_14 || _flags & 1) {
return _data;
} else {
error("Unhandled packed data");
}
}
MemoryObject2::MemoryObject2() {
_data2 = 0;
}

View File

@ -89,7 +89,7 @@ class MemoryObject : CObject {
char _field_15;
char _field_16;
char _field_17;
void *_data;
byte *_data;
int _dataSize;
int _flags;
NGIArchive *_libHandle;
@ -98,6 +98,8 @@ class MemoryObject : CObject {
MemoryObject();
virtual bool load(MfcArchive &file);
void loadFile(char *filename);
void load() { loadFile(_filename); }
void *getData();
};
class MemoryObject2 : public MemoryObject {