aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/lispref/display.texi18
-rw-r--r--etc/NEWS5
-rw-r--r--src/image.c21
3 files changed, 32 insertions, 12 deletions
diff --git a/doc/lispref/display.texi b/doc/lispref/display.texi
index 3c3ee1fc6a4..fd6820897f3 100644
--- a/doc/lispref/display.texi
+++ b/doc/lispref/display.texi
@@ -5446,12 +5446,14 @@ because omitting them is what indicates the data has the format of an
5446XBM file. The file contents specify the height and width of the image. 5446XBM file. The file contents specify the height and width of the image.
5447 5447
5448@item 5448@item
5449A string or a bool-vector containing the bits of the image (plus perhaps 5449A string or a bool-vector containing the bits of the image (plus
5450some extra bits at the end that will not be used). It should contain at 5450perhaps some extra bits at the end that will not be used). It should
5451least @var{width} * @code{height} bits. In this case, you must specify 5451contain at least @w{@code{@var{stride} * @var{height}}} bits, where
5452@code{:height} and @code{:width}, both to indicate that the string 5452@var{stride} is the smallest multiple of 8 greater than or equal to
5453contains just the bits rather than a whole XBM file, and to specify the 5453the width of the image. In this case, you should specify
5454size of the image. 5454@code{:height}, @code{:width} and @code{:stride}, both to indicate
5455that the string contains just the bits rather than a whole XBM file,
5456and to specify the size of the image.
5455@end itemize 5457@end itemize
5456 5458
5457@item :width @var{width} 5459@item :width @var{width}
@@ -5459,6 +5461,10 @@ The value, @var{width}, specifies the width of the image, in pixels.
5459 5461
5460@item :height @var{height} 5462@item :height @var{height}
5461The value, @var{height}, specifies the height of the image, in pixels. 5463The value, @var{height}, specifies the height of the image, in pixels.
5464
5465@item :stride @var{stride}
5466The number of bool vector entries stored for each row; the smallest
5467multiple of 8 greater than or equal to @var{width}.
5462@end table 5468@end table
5463 5469
5464@node XPM Images 5470@node XPM Images
diff --git a/etc/NEWS b/etc/NEWS
index 50956f4082c..3072d4081b8 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -2152,6 +2152,11 @@ valid event type.
2152--- 2152---
2153** The obsolete package xesam.el (since Emacs 24) has been removed. 2153** The obsolete package xesam.el (since Emacs 24) has been removed.
2154 2154
2155+++
2156** The XBM image handler now accepts a ':stride' argument, which should
2157be specified in image specs representing the entire bitmap as a single
2158bool vector.
2159
2155 2160
2156* Lisp Changes in Emacs 27.1 2161* Lisp Changes in Emacs 27.1
2157 2162
diff --git a/src/image.c b/src/image.c
index d9b7101d658..06a8154842c 100644
--- a/src/image.c
+++ b/src/image.c
@@ -3028,6 +3028,7 @@ enum xbm_keyword_index
3028 XBM_FILE, 3028 XBM_FILE,
3029 XBM_WIDTH, 3029 XBM_WIDTH,
3030 XBM_HEIGHT, 3030 XBM_HEIGHT,
3031 XBM_STRIDE,
3031 XBM_DATA, 3032 XBM_DATA,
3032 XBM_FOREGROUND, 3033 XBM_FOREGROUND,
3033 XBM_BACKGROUND, 3034 XBM_BACKGROUND,
@@ -3049,6 +3050,7 @@ static const struct image_keyword xbm_format[XBM_LAST] =
3049 {":file", IMAGE_STRING_VALUE, 0}, 3050 {":file", IMAGE_STRING_VALUE, 0},
3050 {":width", IMAGE_POSITIVE_INTEGER_VALUE, 0}, 3051 {":width", IMAGE_POSITIVE_INTEGER_VALUE, 0},
3051 {":height", IMAGE_POSITIVE_INTEGER_VALUE, 0}, 3052 {":height", IMAGE_POSITIVE_INTEGER_VALUE, 0},
3053 {":stride", IMAGE_POSITIVE_INTEGER_VALUE, 0},
3052 {":data", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, 3054 {":data", IMAGE_DONT_CHECK_VALUE_TYPE, 0},
3053 {":foreground", IMAGE_STRING_OR_NIL_VALUE, 0}, 3055 {":foreground", IMAGE_STRING_OR_NIL_VALUE, 0},
3054 {":background", IMAGE_STRING_OR_NIL_VALUE, 0}, 3056 {":background", IMAGE_STRING_OR_NIL_VALUE, 0},
@@ -3124,7 +3126,7 @@ xbm_image_p (Lisp_Object object)
3124 else 3126 else
3125 { 3127 {
3126 Lisp_Object data; 3128 Lisp_Object data;
3127 int width, height; 3129 int width, height, stride;
3128 3130
3129 /* Entries for `:width', `:height' and `:data' must be present. */ 3131 /* Entries for `:width', `:height' and `:data' must be present. */
3130 if (!kw[XBM_WIDTH].count 3132 if (!kw[XBM_WIDTH].count
@@ -3136,6 +3138,11 @@ xbm_image_p (Lisp_Object object)
3136 width = XFIXNAT (kw[XBM_WIDTH].value); 3138 width = XFIXNAT (kw[XBM_WIDTH].value);
3137 height = XFIXNAT (kw[XBM_HEIGHT].value); 3139 height = XFIXNAT (kw[XBM_HEIGHT].value);
3138 3140
3141 if (!kw[XBM_STRIDE].count)
3142 stride = width;
3143 else
3144 stride = XFIXNAT (kw[XBM_STRIDE].value);
3145
3139 /* Check type of data, and width and height against contents of 3146 /* Check type of data, and width and height against contents of
3140 data. */ 3147 data. */
3141 if (VECTORP (data)) 3148 if (VECTORP (data))
@@ -3154,8 +3161,7 @@ xbm_image_p (Lisp_Object object)
3154 3161
3155 if (STRINGP (elt)) 3162 if (STRINGP (elt))
3156 { 3163 {
3157 if (SCHARS (elt) 3164 if (SCHARS (elt) < stride / CHAR_BIT)
3158 < (width + CHAR_BIT - 1) / CHAR_BIT)
3159 return 0; 3165 return 0;
3160 } 3166 }
3161 else if (BOOL_VECTOR_P (elt)) 3167 else if (BOOL_VECTOR_P (elt))
@@ -3169,13 +3175,16 @@ xbm_image_p (Lisp_Object object)
3169 } 3175 }
3170 else if (STRINGP (data)) 3176 else if (STRINGP (data))
3171 { 3177 {
3172 if (SCHARS (data) 3178 if (SCHARS (data) < stride / CHAR_BIT * height)
3173 < (width + CHAR_BIT - 1) / CHAR_BIT * height)
3174 return 0; 3179 return 0;
3175 } 3180 }
3176 else if (BOOL_VECTOR_P (data)) 3181 else if (BOOL_VECTOR_P (data))
3177 { 3182 {
3178 if (bool_vector_size (data) / height < width) 3183 if (height > 1 && stride != (width + CHAR_BIT - 1)
3184 / CHAR_BIT * CHAR_BIT)
3185 return 0;
3186
3187 if (bool_vector_size (data) / height < stride)
3179 return 0; 3188 return 0;
3180 } 3189 }
3181 else 3190 else