+ /* calculate new image dimensions for final image size */
+ width_final = old_width * zoom_factor;
+ height_final = old_height * zoom_factor;
+
+ /* get image with final size (this might require scaling up) */
+ /* ("final" size may result in non-standard tile size image) */
+ if (zoom_factor != 1)
+ tmp_bitmap_final = ZoomBitmap(old_bitmap, width_final, height_final);
+ else
+ tmp_bitmap_final = old_bitmap;
+
+ UPDATE_BUSY_STATE();
+
+ width_0 = width_1 = width_final;
+ height_0 = height_1 = height_final;
+
+ tmp_bitmap_0 = tmp_bitmap_1 = tmp_bitmap_final;
+
+ if (create_small_bitmaps)
+ {
+ /* check if we have a non-gameplay tile size image */
+ if (tile_size != gfx.game_tile_size)
+ {
+ /* get image with gameplay tile size */
+ width_0 = width_final * gfx.game_tile_size / tile_size;
+ height_0 = height_final * gfx.game_tile_size / tile_size;
+
+ if (width_0 == old_width)
+ tmp_bitmap_0 = old_bitmap;
+ else if (width_0 == width_final)
+ tmp_bitmap_0 = tmp_bitmap_final;
+ else
+ tmp_bitmap_0 = ZoomBitmap(old_bitmap, width_0, height_0);
+
+ UPDATE_BUSY_STATE();
+ }
+
+ /* check if we have a non-standard tile size image */
+ if (tile_size != gfx.standard_tile_size)
+ {
+ /* get image with standard tile size */
+ width_1 = width_final * gfx.standard_tile_size / tile_size;
+ height_1 = height_final * gfx.standard_tile_size / tile_size;
+
+ if (width_1 == old_width)
+ tmp_bitmap_1 = old_bitmap;
+ else if (width_1 == width_final)
+ tmp_bitmap_1 = tmp_bitmap_final;
+ else if (width_1 == width_0)
+ tmp_bitmap_1 = tmp_bitmap_0;
+ else
+ tmp_bitmap_1 = ZoomBitmap(old_bitmap, width_1, height_1);
+
+ UPDATE_BUSY_STATE();
+ }
+
+ /* calculate new image dimensions for small images */
+ width_2 = width_1 / 2;
+ height_2 = height_1 / 2;
+ width_4 = width_1 / 4;
+ height_4 = height_1 / 4;
+ width_8 = width_1 / 8;
+ height_8 = height_1 / 8;
+ width_16 = width_1 / 16;
+ height_16 = height_1 / 16;
+ width_32 = width_1 / 32;
+ height_32 = height_1 / 32;
+
+ /* get image with 1/2 of normal size (for use in the level editor) */
+ if (width_2 == old_width)
+ tmp_bitmap_2 = old_bitmap;
+ else
+ tmp_bitmap_2 = ZoomBitmap(tmp_bitmap_1, width_2, height_2);
+
+ UPDATE_BUSY_STATE();
+
+ /* get image with 1/4 of normal size (for use in the level editor) */
+ if (width_4 == old_width)
+ tmp_bitmap_4 = old_bitmap;
+ else
+ tmp_bitmap_4 = ZoomBitmap(tmp_bitmap_2, width_4, height_4);
+
+ UPDATE_BUSY_STATE();
+
+ /* get image with 1/8 of normal size (for use on the preview screen) */
+ if (width_8 == old_width)
+ tmp_bitmap_8 = old_bitmap;
+ else
+ tmp_bitmap_8 = ZoomBitmap(tmp_bitmap_4, width_8, height_8);
+
+ UPDATE_BUSY_STATE();
+
+ /* get image with 1/16 of normal size (for use on the preview screen) */
+ if (width_16 == old_width)
+ tmp_bitmap_16 = old_bitmap;
+ else
+ tmp_bitmap_16 = ZoomBitmap(tmp_bitmap_8, width_16, height_16);
+
+ UPDATE_BUSY_STATE();
+
+ /* get image with 1/32 of normal size (for use on the preview screen) */
+ if (width_32 == old_width)
+ tmp_bitmap_32 = old_bitmap;
+ else
+ tmp_bitmap_32 = ZoomBitmap(tmp_bitmap_16, width_32, height_32);
+
+ UPDATE_BUSY_STATE();
+
+ bitmaps[IMG_BITMAP_32x32] = tmp_bitmap_1;
+ bitmaps[IMG_BITMAP_16x16] = tmp_bitmap_2;
+ bitmaps[IMG_BITMAP_8x8] = tmp_bitmap_4;
+ bitmaps[IMG_BITMAP_4x4] = tmp_bitmap_8;
+ bitmaps[IMG_BITMAP_2x2] = tmp_bitmap_16;
+ bitmaps[IMG_BITMAP_1x1] = tmp_bitmap_32;
+
+ if (width_0 != width_1)
+ bitmaps[IMG_BITMAP_CUSTOM] = tmp_bitmap_0;
+
+ if (bitmaps[IMG_BITMAP_CUSTOM])
+ bitmaps[IMG_BITMAP_GAME] = bitmaps[IMG_BITMAP_CUSTOM];
+ else
+ bitmaps[IMG_BITMAP_GAME] = bitmaps[IMG_BITMAP_STANDARD];
+
+ boolean free_old_bitmap = TRUE;
+
+ for (i = 0; i < NUM_IMG_BITMAPS; i++)
+ if (bitmaps[i] == old_bitmap)
+ free_old_bitmap = FALSE;
+
+ if (free_old_bitmap)
+ FreeBitmap(old_bitmap);
+ }
+ else
+ {
+ bitmaps[IMG_BITMAP_32x32] = tmp_bitmap_1;
+ }
+
+ // create corresponding bitmaps for masked blitting
+ for (i = 0; i < NUM_IMG_BITMAPS; i++)
+ if (bitmaps[i] != NULL &&
+ bitmaps[i] != old_bitmap)
+ SetMaskedBitmapSurface(bitmaps[i]);
+
+ UPDATE_BUSY_STATE();
+
+ print_timestamp_done("CreateScaledBitmaps");
+}
+
+void CreateBitmapWithSmallBitmaps(Bitmap **bitmaps, int zoom_factor,
+ int tile_size)
+{
+ CreateScaledBitmaps(bitmaps, zoom_factor, tile_size, TRUE);
+}
+
+void ScaleBitmap(Bitmap **bitmaps, int zoom_factor)
+{
+ CreateScaledBitmaps(bitmaps, zoom_factor, 0, FALSE);