diff options
author | peter1138 <peter1138@openttd.org> | 2011-11-24 12:38:48 +0000 |
---|---|---|
committer | peter1138 <peter1138@openttd.org> | 2011-11-24 12:38:48 +0000 |
commit | 81598273e9b6bb2ee20ebdd82f3d4646a02999ba (patch) | |
tree | 2d13cc93dc84f2d99cff6fc2bb02214d4453f033 /src/spriteloader/grf.cpp | |
parent | 15d0a22aac6b90a2055e68d019cab4350376a8fd (diff) | |
download | openttd-81598273e9b6bb2ee20ebdd82f3d4646a02999ba.tar.xz |
(svn r23316) -Feature: Add ability to zoom in to 2x and 4x level.
Diffstat (limited to 'src/spriteloader/grf.cpp')
-rw-r--r-- | src/spriteloader/grf.cpp | 18 |
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; |