From 6287637ccd9f66a219844231380ab9873d049c6e Mon Sep 17 00:00:00 2001 From: "Basil L. Contovounesios" Date: Thu, 15 Jan 2026 20:24:29 +0100 Subject: [PATCH] Various housekeeping in image.c * doc/lispref/display.texi (Customizing Bitmaps): Fix grammar. (XBM Images): Fix reference to incorrect number of properties. (Multi-Frame Images, Other Image Types): Mention multi-frame WebP support. * src/image.c: Don't include pdumper.h; it hasn't been needed since commit of 2019-05-17 "Clean up and simplify image-type setup". Fix some commentary. (image_pix_container_create_from_bitmap_data): Remove no longer used frame parameter (bug#80191); this continues from commit of 2022-11-25 "Remove unused parameter from image_create_pix_container". All callers updated. (x_create_xrender_picture, initialize_image_type): Simplify. (xbm_image_p): Remove redundant conditional branch. Update commentary. --- doc/lispref/display.texi | 11 +++++---- src/image.c | 49 +++++++++++++++------------------------- 2 files changed, 24 insertions(+), 36 deletions(-) diff --git a/doc/lispref/display.texi b/doc/lispref/display.texi index 5f92f23c694..b74e4b9632f 100644 --- a/doc/lispref/display.texi +++ b/doc/lispref/display.texi @@ -4911,7 +4911,7 @@ either a string or a vector of integers, where each element (an integer) corresponds to one row of the bitmap. Each bit of an integer corresponds to one pixel of the bitmap, where the low bit corresponds to the rightmost pixel of the bitmap. (Note that this order of bits -is opposite of the order in XBM images; @pxref{XBM Images}.) +is the opposite of the order in XBM images; @pxref{XBM Images}.) The height is normally the length of @var{bits}. However, you can specify a different height with non-@code{nil} @var{height}. The width @@ -6367,8 +6367,8 @@ used for each pixel in the XBM that is 0. The default is the frame's background color. @end table - If you specify an XBM image using data within Emacs instead of an -external file, use the following three properties: + To specify an XBM image using data within Emacs instead of an +external file, use the following properties: @table @code @item :data @var{data} @@ -6999,6 +6999,7 @@ Supports the @code{:index} property. @xref{Multi-Frame Images}. @item WebP Image type @code{webp}. +Supports the @code{:index} property. @xref{Multi-Frame Images}. @end table @node Defining Images @@ -7320,8 +7321,8 @@ about these image-specific key bindings. @cindex image frames Some image files can contain more than one image. We say that there are multiple ``frames'' in the image. At present, Emacs supports -multiple frames for GIF, TIFF, and certain ImageMagick formats such as -DJVM@. +multiple frames for GIF, TIFF, WebP, and certain ImageMagick formats +such as DJVM@. The frames can be used either to represent multiple pages (this is usually the case with multi-frame TIFF files, for example), or to diff --git a/src/image.c b/src/image.c index 3dad672515c..ac6e76f10a7 100644 --- a/src/image.c +++ b/src/image.c @@ -51,7 +51,6 @@ along with GNU Emacs. If not, see . */ #include "coding.h" #include "termhooks.h" #include "font.h" -#include "pdumper.h" #ifdef HAVE_SYS_STAT_H #include @@ -270,8 +269,7 @@ image_pix_context_get_pixel (Emacs_Pix_Context image, int x, int y) } static Emacs_Pix_Container -image_pix_container_create_from_bitmap_data (struct frame *f, - char *data, unsigned int width, +image_pix_container_create_from_bitmap_data (char *data, unsigned int width, unsigned int height, unsigned long fg, unsigned long bg) @@ -1471,7 +1469,8 @@ struct image_keyword /* True means key must be present. */ bool mandatory_p; - /* Used to recognize duplicate keywords in a property list. */ + /* True means key is present. + Also used to recognize duplicate keywords in a property list. */ bool count; /* The value that was found. */ @@ -3931,7 +3930,7 @@ x_destroy_x_image (XImage *ximg) static Picture x_create_xrender_picture (struct frame *f, Emacs_Pixmap pixmap, int depth) { - Picture p; + Picture p = None; Display *display = FRAME_X_DISPLAY (f); if (FRAME_DISPLAY_INFO (f)->xrender_supported_p) @@ -3966,15 +3965,7 @@ x_create_xrender_picture (struct frame *f, Emacs_Pixmap pixmap, int depth) p = XRenderCreatePicture (display, pixmap, format, attr_mask, &attr); } else - { - image_error ("Specified image bit depth is not supported by XRender"); - return 0; - } - } - else - { - /* XRender not supported on this display. */ - return 0; + image_error ("Specified image bit depth is not supported by XRender"); } return p; @@ -4607,7 +4598,7 @@ enum xbm_token /* Return true if OBJECT is a valid XBM-type image specification. - A valid specification is a list starting with the symbol `image' + A valid specification is a list starting with the symbol `image'. The rest of the list is a property list which must contain an entry `:type xbm'. @@ -4630,8 +4621,8 @@ enum xbm_token Both the file and data forms may contain the additional entries `:background COLOR' and `:foreground COLOR'. If not present, - foreground and background of the frame on which the image is - displayed is used. */ + the foreground and background of the frame on which the image is + displayed are used. */ static bool xbm_image_p (Lisp_Object object) @@ -4649,18 +4640,14 @@ xbm_image_p (Lisp_Object object) if (kw[XBM_DATA].count) return 0; } - else if (kw[XBM_DATA].count && xbm_file_p (kw[XBM_DATA].value)) - { - /* In-memory XBM file. */ - if (kw[XBM_FILE].count) - return 0; - } - else + else if (! (kw[XBM_DATA].count && xbm_file_p (kw[XBM_DATA].value))) + /* Not an in-memory XBM file. */ { Lisp_Object data; int width, height, stride; - /* Entries for `:width', `:height' and `:data' must be present. */ + /* Entries for `:data-width', `:data-height', and `:data' must be + present. */ if (!kw[XBM_DATA_WIDTH].count || !kw[XBM_DATA_HEIGHT].count || !kw[XBM_DATA].count) @@ -4944,7 +4931,7 @@ Create_Pixmap_From_Bitmap_Data (struct frame *f, struct image *img, char *data, fg = lookup_rgb_color (f, fgbg[0].red, fgbg[0].green, fgbg[0].blue); bg = lookup_rgb_color (f, fgbg[1].red, fgbg[1].green, fgbg[1].blue); img->pixmap - = image_pix_container_create_from_bitmap_data (f, data, img->width, + = image_pix_container_create_from_bitmap_data (data, img->width, img->height, fg, bg); #elif defined HAVE_X_WINDOWS img->pixmap @@ -7447,7 +7434,7 @@ image_build_heuristic_mask (struct frame *f, struct image *img, PBM (mono, gray, color) ***********************************************************************/ -/* Indices of image specification fields in gs_format, below. */ +/* Indices of image specification fields in pbm_format, below. */ enum pbm_keyword_index { @@ -8592,7 +8579,7 @@ png_load (struct frame *f, struct image *img) #if defined (HAVE_JPEG) -/* Indices of image specification fields in gs_format, below. */ +/* Indices of image specification fields in jpeg_format, below. */ enum jpeg_keyword_index { @@ -12827,7 +12814,7 @@ initialize_image_type (struct image_type const *type) Lisp_Object tested = Fassq (typesym, Vlibrary_cache); /* If we failed to load the library before, don't try again. */ if (CONSP (tested)) - return !NILP (XCDR (tested)) ? true : false; + return !NILP (XCDR (tested)); bool (*init) (void) = type->init; if (init) @@ -12891,8 +12878,8 @@ static struct image_type native_image_type = image_clear_image }; #endif -/* Look up image type TYPE, and return a pointer to its image_type - structure. Return 0 if TYPE is not a known image type. */ +/* Look up image TYPE, and return a pointer to its image_type structure. + Return a null pointer if TYPE is not a known image type. */ static struct image_type const * lookup_image_type (Lisp_Object type)