Mercurial > emacs
comparison src/xfns.c @ 32549:73521ea30674
(pbm_format): Add :foreground and :background keywords.
(PBM_FOREGROUND, PBM_BACKGROUND): New enumerators.
(xbm_load): Recoghnize foreground and background color
specifications.
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Mon, 16 Oct 2000 19:57:04 +0000 |
parents | c198e3edcae6 |
children | 78b4e9f31087 |
comparison
equal
deleted
inserted
replaced
32548:da8bc20ce19a | 32549:73521ea30674 |
---|---|
7905 PBM_MARGIN, | 7905 PBM_MARGIN, |
7906 PBM_RELIEF, | 7906 PBM_RELIEF, |
7907 PBM_ALGORITHM, | 7907 PBM_ALGORITHM, |
7908 PBM_HEURISTIC_MASK, | 7908 PBM_HEURISTIC_MASK, |
7909 PBM_MASK, | 7909 PBM_MASK, |
7910 PBM_FOREGROUND, | |
7911 PBM_BACKGROUND, | |
7910 PBM_LAST | 7912 PBM_LAST |
7911 }; | 7913 }; |
7912 | 7914 |
7913 /* Vector of image_keyword structures describing the format | 7915 /* Vector of image_keyword structures describing the format |
7914 of valid user-defined image specifications. */ | 7916 of valid user-defined image specifications. */ |
7921 {":ascent", IMAGE_ASCENT_VALUE, 0}, | 7923 {":ascent", IMAGE_ASCENT_VALUE, 0}, |
7922 {":margin", IMAGE_POSITIVE_INTEGER_VALUE, 0}, | 7924 {":margin", IMAGE_POSITIVE_INTEGER_VALUE, 0}, |
7923 {":relief", IMAGE_INTEGER_VALUE, 0}, | 7925 {":relief", IMAGE_INTEGER_VALUE, 0}, |
7924 {":algorithm", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, | 7926 {":algorithm", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, |
7925 {":heuristic-mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, | 7927 {":heuristic-mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, |
7926 {":mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0} | 7928 {":mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, |
7929 {":foreground", IMAGE_STRING_VALUE, 0}, | |
7930 {":background", IMAGE_STRING_VALUE, 0} | |
7927 }; | 7931 }; |
7928 | 7932 |
7929 /* Structure describing the image type `pbm'. */ | 7933 /* Structure describing the image type `pbm'. */ |
7930 | 7934 |
7931 static struct image_type pbm_type = | 7935 static struct image_type pbm_type = |
8110 init_color_table (); | 8114 init_color_table (); |
8111 | 8115 |
8112 if (type == PBM_MONO) | 8116 if (type == PBM_MONO) |
8113 { | 8117 { |
8114 int c = 0, g; | 8118 int c = 0, g; |
8119 struct image_keyword fmt[PBM_LAST]; | |
8120 unsigned long fg = FRAME_FOREGROUND_PIXEL (f); | |
8121 unsigned long bg = FRAME_BACKGROUND_PIXEL (f); | |
8122 | |
8123 /* Parse the image specification. */ | |
8124 bcopy (pbm_format, fmt, sizeof fmt); | |
8125 parse_image_spec (img->spec, fmt, PBM_LAST, Qpbm); | |
8126 | |
8127 /* Get foreground and background colors, maybe allocate colors. */ | |
8128 if (fmt[PBM_FOREGROUND].count) | |
8129 fg = x_alloc_image_color (f, img, fmt[PBM_FOREGROUND].value, fg); | |
8130 if (fmt[PBM_BACKGROUND].count) | |
8131 bg = x_alloc_image_color (f, img, fmt[PBM_BACKGROUND].value, bg); | |
8115 | 8132 |
8116 for (y = 0; y < height; ++y) | 8133 for (y = 0; y < height; ++y) |
8117 for (x = 0; x < width; ++x) | 8134 for (x = 0; x < width; ++x) |
8118 { | 8135 { |
8119 if (raw_p) | 8136 if (raw_p) |
8124 c <<= 1; | 8141 c <<= 1; |
8125 } | 8142 } |
8126 else | 8143 else |
8127 g = pbm_scan_number (&p, end); | 8144 g = pbm_scan_number (&p, end); |
8128 | 8145 |
8129 XPutPixel (ximg, x, y, (g | 8146 XPutPixel (ximg, x, y, g ? fg : bg); |
8130 ? FRAME_FOREGROUND_PIXEL (f) | |
8131 : FRAME_BACKGROUND_PIXEL (f))); | |
8132 } | 8147 } |
8133 } | 8148 } |
8134 else | 8149 else |
8135 { | 8150 { |
8136 for (y = 0; y < height; ++y) | 8151 for (y = 0; y < height; ++y) |