+static void convert_mono_to_color_image (f, img, foreground, background)
+ struct frame *f;
+ struct image *img;
+ COLORREF foreground, background;
+{
+ HDC hdc, old_img_dc, new_img_dc;
+ HGDIOBJ old_prev, new_prev;
+ HBITMAP new_pixmap;
+
+ hdc = get_frame_dc (f);
+ old_img_dc = CreateCompatibleDC (hdc);
+ new_img_dc = CreateCompatibleDC (hdc);
+ new_pixmap = CreateCompatibleBitmap (hdc, img->width, img->height);
+ release_frame_dc (f, hdc);
+ old_prev = SelectObject (old_img_dc, img->pixmap);
+ new_prev = SelectObject (new_img_dc, new_pixmap);
+ SetTextColor (new_img_dc, foreground);
+ SetBkColor (new_img_dc, background);
+
+ BitBlt (new_img_dc, 0, 0, img->width, img->height, old_img_dc,
+ 0, 0, SRCCOPY);
+
+ SelectObject (old_img_dc, old_prev);
+ SelectObject (new_img_dc, new_prev);
+ DeleteDC (old_img_dc);
+ DeleteDC (new_img_dc);
+ DeleteObject (img->pixmap);
+ if (new_pixmap == 0)
+ fprintf (stderr, "Failed to convert image to color.\n");
+ else
+ img->pixmap = new_pixmap;
+}