summaryrefslogtreecommitdiff
path: root/src/spriteloader/grf.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/spriteloader/grf.cpp')
-rw-r--r--src/spriteloader/grf.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/spriteloader/grf.cpp b/src/spriteloader/grf.cpp
index a0f5c8632..2876f2f35 100644
--- a/src/spriteloader/grf.cpp
+++ b/src/spriteloader/grf.cpp
@@ -95,7 +95,7 @@ bool SpriteLoaderGrf::LoadSprite(SpriteLoader::Sprite *sprite, uint8 file_slot,
if (num != 0) return WarnCorruptSprite(file_slot, file_pos, __LINE__);
- sprite->AllocateData(sprite->width * sprite->height);
+ sprite->AllocateData(sprite->width * sprite->height * ZOOM_LVL_BASE * ZOOM_LVL_BASE);
/* When there are transparency pixels, this format has another trick.. decode it */
if (type & 0x08) {
@@ -163,6 +163,22 @@ bool SpriteLoaderGrf::LoadSprite(SpriteLoader::Sprite *sprite, uint8 file_slot,
}
}
+ if (ZOOM_LVL_BASE != 1 && sprite_type == ST_NORMAL) {
+ /* Simple scaling, back-to-front so that no intermediate buffers are needed. */
+ int width = sprite->width * ZOOM_LVL_BASE;
+ int height = sprite->height * ZOOM_LVL_BASE;
+ for (int y = height - 1; y >= 0; y--) {
+ for (int x = width - 1; x >= 0; x--) {
+ sprite->data[y * width + x] = sprite->data[y / ZOOM_LVL_BASE * sprite->width + x / ZOOM_LVL_BASE];
+ }
+ }
+
+ sprite->width *= ZOOM_LVL_BASE;
+ sprite->height *= ZOOM_LVL_BASE;
+ sprite->x_offs *= ZOOM_LVL_BASE;
+ sprite->y_offs *= ZOOM_LVL_BASE;
+ }
+
/* Make sure to mark all transparent pixels transparent on the alpha channel too */
for (int i = 0; i < sprite->width * sprite->height; i++) {
if (sprite->data[i].m != 0) sprite->data[i].a = 0xFF;