ASYLUM: Fix rendering if width != pitch in 8bpp

The reason why the engine needs linearly allocated surface is
Cursor::update() which passes cursor surfaces directly to
CursorMan::replaceCursor().
This commit is contained in:
Miro Kropacek committed 2023-04-03 21:19:49 +02:00
1 parent cb5b2dc021
commit 39c53260a2
1 file changed
+2 -2
+2 -2
View File
@@ -57,7 +57,7 @@ bool GraphicResource::load(ResourceId id) {
void GraphicResource::clear() {
for (uint32 i = 0; i < _frames.size(); i++) {
_frames[i].surface.free();
delete[] (byte*)_frames[i].surface.getPixels();
}
_frames.clear();
@@ -141,7 +141,7 @@ void GraphicResource::init(byte *data, int32 size) {
uint16 width = READ_LE_UINT16(dataPtr);
dataPtr += 2;
_frames[i].surface.create(width, height, Graphics::PixelFormat::createFormatCLUT8());
_frames[i].surface.init(width, height, width, new byte[width * height], Graphics::PixelFormat::createFormatCLUT8());
memcpy(_frames[i].surface.getPixels(), dataPtr, (size_t)(width * height));
}