[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 144e9f9b6a: Fix file-based stipple on NS
From: |
Po Lu |
Subject: |
master 144e9f9b6a: Fix file-based stipple on NS |
Date: |
Sun, 8 May 2022 02:28:54 -0400 (EDT) |
branch: master
commit 144e9f9b6a376ec0349557ef10a6c133228cda26
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>
Fix file-based stipple on NS
* src/image.c (image_create_bitmap_from_file) [HAVE_NS]: Fix
loading XBM data from file.
---
src/image.c | 34 +++++++++++++++++++++++++++++++---
1 file changed, 31 insertions(+), 3 deletions(-)
diff --git a/src/image.c b/src/image.c
index f3b47f7ccc..6cd0aa48cf 100644
--- a/src/image.c
+++ b/src/image.c
@@ -611,7 +611,7 @@ image_create_bitmap_from_data (struct frame *f, char *bits,
return id;
}
-#ifdef HAVE_HAIKU
+#if defined HAVE_HAIKU || defined HAVE_NS
static char *slurp_file (int, ptrdiff_t *);
static Lisp_Object image_find_image_fd (Lisp_Object, int *);
static bool xbm_read_bitmap_data (struct frame *, char *, char *,
@@ -630,11 +630,36 @@ image_create_bitmap_from_file (struct frame *f,
Lisp_Object file)
#endif
#ifdef HAVE_NS
- ptrdiff_t id;
- void *bitmap = ns_image_from_file (file);
+ ptrdiff_t id, size;
+ int fd, width, height, rc;
+ char *contents, *data;
+ void *bitmap;
+
+ if (!STRINGP (image_find_image_fd (file, &fd)))
+ return -1;
+
+ contents = slurp_file (fd, &size);
+
+ if (!contents)
+ return -1;
+
+ rc = xbm_read_bitmap_data (f, contents, contents + size,
+ &width, &height, &data, 0);
+
+ if (!rc)
+ {
+ xfree (contents);
+ return -1;
+ }
+
+ bitmap = ns_image_from_XBM (data, width, height, 0, 0);
if (!bitmap)
+ {
+ xfree (contents);
+ xfree (data);
return -1;
+ }
id = image_allocate_bitmap_record (f);
dpyinfo->bitmaps[id - 1].img = bitmap;
@@ -643,6 +668,9 @@ image_create_bitmap_from_file (struct frame *f, Lisp_Object
file)
dpyinfo->bitmaps[id - 1].depth = 1;
dpyinfo->bitmaps[id - 1].height = ns_image_width (bitmap);
dpyinfo->bitmaps[id - 1].width = ns_image_height (bitmap);
+
+ xfree (contents);
+ xfree (data);
return id;
#endif
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 144e9f9b6a: Fix file-based stipple on NS,
Po Lu <=