added alpha channel for anti-aliasing to element collecting image
authorHolger Schemel <info@artsoft.org>
Sat, 6 Aug 2022 09:08:45 +0000 (11:08 +0200)
committerHolger Schemel <info@artsoft.org>
Sat, 6 Aug 2022 09:10:21 +0000 (11:10 +0200)
graphics/gfx_classic/RocksCollect.png
src/files.c

index 0f5a1dfc4602893bcd10ee0f131e31d8535f5a54..710c556cb1085d441a54435118f702c2deb97e7a 100644 (file)
Binary files a/graphics/gfx_classic/RocksCollect.png and b/graphics/gfx_classic/RocksCollect.png differ
index 1d8ba0269fb377ab486a604d01af18be45fc0fd7..09e3b4d2256fcfe7d7cee4b6c655070f57aee90b 100644 (file)
@@ -13466,6 +13466,13 @@ void CreateCollectElementImages(void)
           filename_bmp,
           filename_png);
 
+  // force using RGBA surface for destination bitmap
+  SDL_SetColorKey(dst_bitmap->surface, SET_TRANSPARENT_PIXEL,
+                 SDL_MapRGB(dst_bitmap->surface->format, 0x00, 0x00, 0x00));
+
+  dst_bitmap->surface =
+    SDL_ConvertSurfaceFormat(dst_bitmap->surface, SDL_PIXELFORMAT_RGBA32, 0);
+
   for (i = 0; i < MAX_NUM_ELEMENTS; i++)
   {
     if (!createCollectImage(i))
@@ -13486,6 +13493,13 @@ void CreateCollectElementImages(void)
     BlitBitmap(src_bitmap, tmp_bitmap, src_x, src_y,
               tile_size, tile_size, 0, 0);
 
+    // force using RGBA surface for temporary bitmap (using transparent black)
+    SDL_SetColorKey(tmp_bitmap->surface, SET_TRANSPARENT_PIXEL,
+                   SDL_MapRGB(tmp_bitmap->surface->format, 0x00, 0x00, 0x00));
+
+    tmp_bitmap->surface =
+      SDL_ConvertSurfaceFormat(tmp_bitmap->surface, SDL_PIXELFORMAT_RGBA32, 0);
+
     tmp_bitmap->surface_masked = tmp_bitmap->surface;
 
     for (j = 0; j < anim_frames; j++)
@@ -13506,9 +13520,9 @@ void CreateCollectElementImages(void)
        frame_bitmap = half_bitmap;
       }
 
-      BlitBitmap(frame_bitmap, dst_bitmap, 0, 0,
-                frame_size_final, frame_size_final,
-                dst_x + j * tile_size + offset, dst_y + offset);
+      BlitBitmapMasked(frame_bitmap, dst_bitmap, 0, 0,
+                      frame_size_final, frame_size_final,
+                      dst_x + j * tile_size + offset, dst_y + offset);
 
       FreeBitmap(frame_bitmap);
     }