(svn r23316) -Feature: Add ability to zoom in to 2x and 4x level.
This commit is contained in:
@@ -115,7 +115,7 @@ static bool LoadPNG(SpriteLoader::Sprite *sprite, const char *filename, uint32 i
|
||||
}
|
||||
sprite->height = height;
|
||||
sprite->width = width;
|
||||
sprite->AllocateData(sprite->width * sprite->height);
|
||||
sprite->AllocateData(sprite->width * sprite->height * ZOOM_LVL_BASE * ZOOM_LVL_BASE);
|
||||
} else if (sprite->height != png_get_image_height(png_ptr, info_ptr) || sprite->width != png_get_image_width(png_ptr, info_ptr)) {
|
||||
/* Make sure the mask image isn't larger than the sprite image. */
|
||||
DEBUG(misc, 0, "Ignoring mask for SpriteID %d as it isn't the same dimension as the masked sprite", id);
|
||||
@@ -214,6 +214,23 @@ bool SpriteLoaderPNG::LoadSprite(SpriteLoader::Sprite *sprite, uint8 file_slot,
|
||||
const char *filename = FioGetFilename(file_slot);
|
||||
if (!LoadPNG(sprite, filename, (uint32)file_pos, false)) return false;
|
||||
if (!LoadPNG(sprite, filename, (uint32)file_pos, true)) return false;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user