From: Holger Schemel Date: Sat, 6 Aug 2022 08:42:44 +0000 (+0200) Subject: changed function to write element collecting image to create PNG file X-Git-Tag: 4.3.3.0~75 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=f6fe208025315d57ad9ed432ad11b6a8c463684c;p=rocksndiamonds.git changed function to write element collecting image to create PNG file --- diff --git a/graphics/gfx_classic/RocksCollect.png b/graphics/gfx_classic/RocksCollect.png index e5a72bfb..0f5a1dfc 100644 Binary files a/graphics/gfx_classic/RocksCollect.png and b/graphics/gfx_classic/RocksCollect.png differ diff --git a/src/files.c b/src/files.c index 8889f810..1d8ba026 100644 --- a/src/files.c +++ b/src/files.c @@ -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);