diff options
| author | Jason Rumney | 2002-11-20 23:14:20 +0000 |
|---|---|---|
| committer | Jason Rumney | 2002-11-20 23:14:20 +0000 |
| commit | 516eea8e3c3d20d55c8837369a0c9782ac330317 (patch) | |
| tree | 7a5430fc2b72c1007dc221c73185bbcfd05e1c99 /src | |
| parent | 39f7b5f7f63c4f14812746e16c09c1e83b69f7af (diff) | |
| download | emacs-516eea8e3c3d20d55c8837369a0c9782ac330317.tar.gz emacs-516eea8e3c3d20d55c8837369a0c9782ac330317.zip | |
(convert_mono_to_color_image): New function.
(xbm_load, xbm_load_image): Use it when foreground or background
is explicitly set.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 6 | ||||
| -rw-r--r-- | src/w32fns.c | 63 |
2 files changed, 64 insertions, 5 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index ac87188b89f..ca5d94449ea 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2002-11-20 Jason Rumney <jasonr@gnu.org> | ||
| 2 | |||
| 3 | * w32fns.c (convert_mono_to_color_image): New function. | ||
| 4 | (xbm_load, xbm_load_image): Use it when foreground or background | ||
| 5 | is explicitly set. | ||
| 6 | |||
| 1 | 2002-11-19 Dave Love <fx@gnu.org> | 7 | 2002-11-19 Dave Love <fx@gnu.org> |
| 2 | 8 | ||
| 3 | * s/usg5-4.h, sco4.h (bcopy, bzero, bcmp): Don't define. | 9 | * s/usg5-4.h, sco4.h (bcopy, bzero, bcmp): Don't define. |
diff --git a/src/w32fns.c b/src/w32fns.c index 93e0be60b83..86984597e99 100644 --- a/src/w32fns.c +++ b/src/w32fns.c | |||
| @@ -9999,6 +9999,38 @@ xbm_read_bitmap_data (contents, end, width, height, data) | |||
| 9999 | #undef expect_ident | 9999 | #undef expect_ident |
| 10000 | } | 10000 | } |
| 10001 | 10001 | ||
| 10002 | static void convert_mono_to_color_image (f, img, foreground, background) | ||
| 10003 | struct frame *f; | ||
| 10004 | struct image *img; | ||
| 10005 | COLORREF foreground, background; | ||
| 10006 | { | ||
| 10007 | HDC hdc, old_img_dc, new_img_dc; | ||
| 10008 | HGDIOBJ old_prev, new_prev; | ||
| 10009 | HBITMAP new_pixmap; | ||
| 10010 | |||
| 10011 | hdc = get_frame_dc (f); | ||
| 10012 | old_img_dc = CreateCompatibleDC (hdc); | ||
| 10013 | new_img_dc = CreateCompatibleDC (hdc); | ||
| 10014 | new_pixmap = CreateCompatibleBitmap (hdc, img->width, img->height); | ||
| 10015 | release_frame_dc (f, hdc); | ||
| 10016 | old_prev = SelectObject (old_img_dc, img->pixmap); | ||
| 10017 | new_prev = SelectObject (new_img_dc, new_pixmap); | ||
| 10018 | SetTextColor (new_img_dc, foreground); | ||
| 10019 | SetBkColor (new_img_dc, background); | ||
| 10020 | |||
| 10021 | BitBlt (new_img_dc, 0, 0, img->width, img->height, old_img_dc, | ||
| 10022 | 0, 0, SRCCOPY); | ||
| 10023 | |||
| 10024 | SelectObject (old_img_dc, old_prev); | ||
| 10025 | SelectObject (new_img_dc, new_prev); | ||
| 10026 | DeleteDC (old_img_dc); | ||
| 10027 | DeleteDC (new_img_dc); | ||
| 10028 | DeleteObject (img->pixmap); | ||
| 10029 | if (new_pixmap == 0) | ||
| 10030 | fprintf (stderr, "Failed to convert image to color.\n"); | ||
| 10031 | else | ||
| 10032 | img->pixmap = new_pixmap; | ||
| 10033 | } | ||
| 10002 | 10034 | ||
| 10003 | /* Load XBM image IMG which will be displayed on frame F from buffer | 10035 | /* Load XBM image IMG which will be displayed on frame F from buffer |
| 10004 | CONTENTS. END is the end of the buffer. Value is non-zero if | 10036 | CONTENTS. END is the end of the buffer. Value is non-zero if |
| @@ -10019,6 +10051,7 @@ xbm_load_image (f, img, contents, end) | |||
| 10019 | { | 10051 | { |
| 10020 | unsigned long foreground = FRAME_FOREGROUND_PIXEL (f); | 10052 | unsigned long foreground = FRAME_FOREGROUND_PIXEL (f); |
| 10021 | unsigned long background = FRAME_BACKGROUND_PIXEL (f); | 10053 | unsigned long background = FRAME_BACKGROUND_PIXEL (f); |
| 10054 | int non_default_colors = 0; | ||
| 10022 | Lisp_Object value; | 10055 | Lisp_Object value; |
| 10023 | 10056 | ||
| 10024 | xassert (img->width > 0 && img->height > 0); | 10057 | xassert (img->width > 0 && img->height > 0); |
| @@ -10026,17 +10059,25 @@ xbm_load_image (f, img, contents, end) | |||
| 10026 | /* Get foreground and background colors, maybe allocate colors. */ | 10059 | /* Get foreground and background colors, maybe allocate colors. */ |
| 10027 | value = image_spec_value (img->spec, QCforeground, NULL); | 10060 | value = image_spec_value (img->spec, QCforeground, NULL); |
| 10028 | if (!NILP (value)) | 10061 | if (!NILP (value)) |
| 10029 | foreground = x_alloc_image_color (f, img, value, foreground); | 10062 | { |
| 10063 | foreground = x_alloc_image_color (f, img, value, foreground); | ||
| 10064 | non_default_colors = 1; | ||
| 10065 | } | ||
| 10030 | value = image_spec_value (img->spec, QCbackground, NULL); | 10066 | value = image_spec_value (img->spec, QCbackground, NULL); |
| 10031 | if (!NILP (value)) | 10067 | if (!NILP (value)) |
| 10032 | { | 10068 | { |
| 10033 | background = x_alloc_image_color (f, img, value, background); | 10069 | background = x_alloc_image_color (f, img, value, background); |
| 10034 | img->background = background; | 10070 | img->background = background; |
| 10035 | img->background_valid = 1; | 10071 | img->background_valid = 1; |
| 10072 | non_default_colors = 1; | ||
| 10036 | } | 10073 | } |
| 10037 | img->pixmap | 10074 | img->pixmap |
| 10038 | = w32_create_pixmap_from_bitmap_data (img->width, img->height, data); | 10075 | = w32_create_pixmap_from_bitmap_data (img->width, img->height, data); |
| 10039 | 10076 | ||
| 10077 | /* If colors were specified, transfer the bitmap to a color one. */ | ||
| 10078 | if (non_default_colors) | ||
| 10079 | convert_mono_to_color_image (f, img, foreground, background); | ||
| 10080 | |||
| 10040 | xfree (data); | 10081 | xfree (data); |
| 10041 | 10082 | ||
| 10042 | if (img->pixmap == 0) | 10083 | if (img->pixmap == 0) |
| @@ -10117,6 +10158,7 @@ xbm_load (f, img) | |||
| 10117 | Lisp_Object data; | 10158 | Lisp_Object data; |
| 10118 | unsigned long foreground = FRAME_FOREGROUND_PIXEL (f); | 10159 | unsigned long foreground = FRAME_FOREGROUND_PIXEL (f); |
| 10119 | unsigned long background = FRAME_BACKGROUND_PIXEL (f); | 10160 | unsigned long background = FRAME_BACKGROUND_PIXEL (f); |
| 10161 | int non_default_colors = 0; | ||
| 10120 | char *bits; | 10162 | char *bits; |
| 10121 | int parsed_p; | 10163 | int parsed_p; |
| 10122 | int in_memory_file_p = 0; | 10164 | int in_memory_file_p = 0; |
| @@ -10141,12 +10183,19 @@ xbm_load (f, img) | |||
| 10141 | /* Get foreground and background colors, maybe allocate colors. */ | 10183 | /* Get foreground and background colors, maybe allocate colors. */ |
| 10142 | if (fmt[XBM_FOREGROUND].count | 10184 | if (fmt[XBM_FOREGROUND].count |
| 10143 | && STRINGP (fmt[XBM_FOREGROUND].value)) | 10185 | && STRINGP (fmt[XBM_FOREGROUND].value)) |
| 10144 | foreground = x_alloc_image_color (f, img, fmt[XBM_FOREGROUND].value, | 10186 | { |
| 10145 | foreground); | 10187 | foreground = x_alloc_image_color (f, img, fmt[XBM_FOREGROUND].value, |
| 10188 | foreground); | ||
| 10189 | non_default_colors = 1; | ||
| 10190 | } | ||
| 10191 | |||
| 10146 | if (fmt[XBM_BACKGROUND].count | 10192 | if (fmt[XBM_BACKGROUND].count |
| 10147 | && STRINGP (fmt[XBM_BACKGROUND].value)) | 10193 | && STRINGP (fmt[XBM_BACKGROUND].value)) |
| 10148 | background = x_alloc_image_color (f, img, fmt[XBM_BACKGROUND].value, | 10194 | { |
| 10149 | background); | 10195 | background = x_alloc_image_color (f, img, fmt[XBM_BACKGROUND].value, |
| 10196 | background); | ||
| 10197 | non_default_colors = 1; | ||
| 10198 | } | ||
| 10150 | 10199 | ||
| 10151 | if (in_memory_file_p) | 10200 | if (in_memory_file_p) |
| 10152 | success_p = xbm_load_image (f, img, SDATA (data), | 10201 | success_p = xbm_load_image (f, img, SDATA (data), |
| @@ -10180,6 +10229,10 @@ xbm_load (f, img) | |||
| 10180 | = w32_create_pixmap_from_bitmap_data (img->width, img->height, | 10229 | = w32_create_pixmap_from_bitmap_data (img->width, img->height, |
| 10181 | bits); | 10230 | bits); |
| 10182 | 10231 | ||
| 10232 | /* If colors were specified, transfer the bitmap to a color one. */ | ||
| 10233 | if (non_default_colors) | ||
| 10234 | convert_mono_to_color_image (f, img, foreground, background); | ||
| 10235 | |||
| 10183 | if (img->pixmap) | 10236 | if (img->pixmap) |
| 10184 | success_p = 1; | 10237 | success_p = 1; |
| 10185 | else | 10238 | else |