changed function to write element collecting image to create PNG file
authorHolger Schemel <info@artsoft.org>
Sat, 6 Aug 2022 08:42:44 +0000 (10:42 +0200)
committerHolger Schemel <info@artsoft.org>
Sat, 6 Aug 2022 08:42:44 +0000 (10:42 +0200)
graphics/gfx_classic/RocksCollect.png
src/files.c

index e5a72bfb78b8459b50e3ff791028e0bcaf96ede6..0f5a1dfc4602893bcd10ee0f131e31d8535f5a54 100644 (file)
Binary files a/graphics/gfx_classic/RocksCollect.png and b/graphics/gfx_classic/RocksCollect.png differ
index 8889f810ecaf59d121a62cbf506fb558757c4f9b..1d8ba0269fb377ab486a604d01af18be45fc0fd7 100644 (file)
@@ -13453,8 +13453,18 @@ void CreateCollectElementImages(void)
   int dst_width  = anim_width * 2;
   int dst_height = anim_height * num_collect_images / 2;
   Bitmap *dst_bitmap = CreateBitmap(dst_width, dst_height, DEFAULT_DEPTH);
-  char *basename = "RocksCollect.bmp";
-  char *filename = getPath2(global.create_collect_images_dir, basename);
+  char *basename_bmp = "RocksCollect.bmp";
+  char *basename_png = "RocksCollect.png";
+  char *filename_bmp = getPath2(global.create_collect_images_dir, basename_bmp);
+  char *filename_png = getPath2(global.create_collect_images_dir, basename_png);
+  int len_filename_bmp = strlen(filename_bmp);
+  int len_filename_png = strlen(filename_png);
+  int max_command_len = MAX_FILENAME_LEN + len_filename_bmp + len_filename_png;
+  char cmd_convert[max_command_len];
+
+  snprintf(cmd_convert, max_command_len, "convert \"%s\" \"%s\"",
+          filename_bmp,
+          filename_png);
 
   for (i = 0; i < MAX_NUM_ELEMENTS; i++)
   {
@@ -13510,11 +13520,16 @@ void CreateCollectElementImages(void)
     pos_collect_images++;
   }
 
-  if (SDL_SaveBMP(dst_bitmap->surface, filename) != 0)
-    Fail("cannot save element collecting image file '%s'", filename);
+  if (SDL_SaveBMP(dst_bitmap->surface, filename_bmp) != 0)
+    Fail("cannot save element collecting image file '%s'", filename_bmp);
 
   FreeBitmap(dst_bitmap);
 
+  Info("Converting image file from BMP to PNG ...");
+
+  system(cmd_convert);
+  unlink(filename_bmp);
+
   Info("Done.");
 
   CloseAllAndExit(0);