+void ReloadCustomImage(Bitmap *bitmap, char *basename)
+{
+ char *filename = getCustomImageFilename(basename);
+ Bitmap *new_bitmap;
+
+ if (filename == NULL) /* (should never happen) */
+ {
+ Error(ERR_WARN, "ReloadCustomImage(): cannot find file '%s'", basename);
+ return;
+ }
+
+ if (strcmp(filename, bitmap->source_filename) == 0)
+ {
+ /* The old and new image are the same (have the same filename and path).
+ This usually means that this image does not exist in this graphic set
+ and a fallback to the existing image is done. */
+
+ return;
+ }
+
+ if ((new_bitmap = LoadImage(filename)) == NULL)
+ {
+ Error(ERR_WARN, "LoadImage() failed: %s", GetError());
+ return;
+ }
+
+ if (bitmap->width != new_bitmap->width ||
+ bitmap->height != new_bitmap->height)
+ {
+ Error(ERR_WARN, "ReloadCustomImage: new image '%s' has wrong dimensions",
+ filename);
+ FreeBitmap(new_bitmap);
+ return;
+ }
+
+ TransferBitmapPointers(new_bitmap, bitmap);
+ free(new_bitmap);
+}
+
+Bitmap *ZoomBitmap(Bitmap *src_bitmap, int zoom_width, int zoom_height)
+{
+ Bitmap *dst_bitmap = CreateBitmap(zoom_width, zoom_height, DEFAULT_DEPTH);
+
+#if defined(TARGET_SDL)
+ SDLZoomBitmap(src_bitmap, dst_bitmap);
+#else
+ X11ZoomBitmap(src_bitmap, dst_bitmap);
+#endif
+
+ return dst_bitmap;
+}
+
+void CreateBitmapWithSmallBitmaps(Bitmap *src_bitmap)
+{
+ Bitmap *tmp_bitmap, *tmp_bitmap_2, *tmp_bitmap_8;
+ int src_width, src_height;
+ int tmp_width, tmp_height;
+
+ src_width = src_bitmap->width;
+ src_height = src_bitmap->height;
+
+ tmp_width = src_width;
+ tmp_height = src_height + src_height / 2;
+
+ tmp_bitmap = CreateBitmap(tmp_width, tmp_height, DEFAULT_DEPTH);
+
+ tmp_bitmap_2 = ZoomBitmap(src_bitmap, src_width / 2, src_height / 2);
+ tmp_bitmap_8 = ZoomBitmap(src_bitmap, src_width / 8, src_height / 8);
+
+ BlitBitmap(src_bitmap, tmp_bitmap, 0, 0, src_width, src_height, 0, 0);
+ BlitBitmap(tmp_bitmap_2, tmp_bitmap, 0, 0, src_width / 2, src_height / 2,
+ 0, src_height);
+ BlitBitmap(tmp_bitmap_8, tmp_bitmap, 0, 0, src_width / 8, src_height / 8,
+ 3 * src_width / 4, src_height);
+
+ FreeBitmap(tmp_bitmap_2);
+ FreeBitmap(tmp_bitmap_8);
+
+#ifdef TARGET_SDL
+ src_bitmap->surface = tmp_bitmap->surface;
+ tmp_bitmap->surface = NULL;
+#else
+ src_bitmap->drawable = tmp_bitmap->drawable;
+ tmp_bitmap->drawable = None;
+#endif
+
+ src_bitmap->height = tmp_bitmap->height;
+
+ FreeBitmap(tmp_bitmap);
+}
+