From: Pip Cet <pipcet@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 36337@debbugs.gnu.org, triska@metalevel.at
Subject: bug#36337: 26.1; XBM images are sometimes not displayed correctly
Date: Sat, 29 Jun 2019 07:20:26 +0000 [thread overview]
Message-ID: <CAOqdjBfjB7OZtDczTfucAf+DsoR8eBgm5bdR6Jn6zKOm+K2k+g@mail.gmail.com> (raw)
In-Reply-To: <8336jtj2xo.fsf@gnu.org>
[-- Attachment #1: Type: text/plain, Size: 774 bytes --]
On Fri, Jun 28, 2019 at 12:45 PM Eli Zaretskii <eliz@gnu.org> wrote:
> > Having thought about it, I would rather require the bool vector passed
> > to XBM to be in the right format: the width can be 100, but the
> > stride, specified by a new :stride argument, must be the smallest
> > multiple of 8 greater or equal to the width. If you don't want that,
> > pass a vector of bool vectors which is copied together, but let's not
> > pretend we can take a 10,000-bit bool vector and display it
> > efficiently.
>
> I'm not sure I understand what you mean, exactly. Can you show an
> example of the new API?
No major changes, just that :stride is passed in along with :height
and :width (optional for now, but strongly recommended by the
documentation). See attached patch.
[-- Attachment #2: 0001-Allow-a-stride-argument-so-XBM-boolvecs-are-in-the-r.patch --]
[-- Type: text/x-patch, Size: 3762 bytes --]
From 2b8afbef133edb9947332b114f37582ae96ef1af Mon Sep 17 00:00:00 2001
From: Pip Cet <pipcet@gmail.com>
Date: Sat, 29 Jun 2019 07:15:52 +0000
Subject: [PATCH] Allow a :stride argument so XBM boolvecs are in the right
format.
Bug#36337
* src/image.c (xbm_image_p): Explicitly specify the right stride if a
bool vector is used as argument.
* doc/lispref/display.texi (XBM Images): Describe bool vectors
accurately.
---
doc/lispref/display.texi | 18 ++++++++++++------
src/image.c | 14 ++++++++++++--
2 files changed, 24 insertions(+), 8 deletions(-)
diff --git a/doc/lispref/display.texi b/doc/lispref/display.texi
index 217df3b2cc..8e7d621b41 100644
--- a/doc/lispref/display.texi
+++ b/doc/lispref/display.texi
@@ -5409,12 +5409,14 @@ XBM Images
XBM file. The file contents specify the height and width of the image.
@item
-A string or a bool-vector containing the bits of the image (plus perhaps
-some extra bits at the end that will not be used). It should contain at
-least @var{width} * @code{height} bits. In this case, you must specify
-@code{:height} and @code{:width}, both to indicate that the string
-contains just the bits rather than a whole XBM file, and to specify the
-size of the image.
+A string or a bool-vector containing the bits of the image (plus
+perhaps some extra bits at the end that will not be used). It should
+contain at least @var{stride} * @code{height} bits, where @var{stride}
+is the smallest multiple of 8 greater than or equal to the width of
+the image. In this case, you should specify @code{:height},
+@code{:width} and @code{:stride}, both to indicate that the string
+contains just the bits rather than a whole XBM file, and to specify
+the size of the image.
@end itemize
@item :width @var{width}
@@ -5422,6 +5424,10 @@ XBM Images
@item :height @var{height}
The value, @var{height}, specifies the height of the image, in pixels.
+
+@item :stride @var{stride}
+The number of bool vector entries stored for each row; the smallest
+multiple of 8 greater than or equal to @var{width}.
@end table
@node XPM Images
diff --git a/src/image.c b/src/image.c
index f3d6508f46..f628fe46db 100644
--- a/src/image.c
+++ b/src/image.c
@@ -3095,6 +3095,7 @@ slurp_file (int fd, ptrdiff_t *size)
XBM_FILE,
XBM_WIDTH,
XBM_HEIGHT,
+ XBM_STRIDE,
XBM_DATA,
XBM_FOREGROUND,
XBM_BACKGROUND,
@@ -3116,6 +3117,7 @@ slurp_file (int fd, ptrdiff_t *size)
{":file", IMAGE_STRING_VALUE, 0},
{":width", IMAGE_POSITIVE_INTEGER_VALUE, 0},
{":height", IMAGE_POSITIVE_INTEGER_VALUE, 0},
+ {":stride", IMAGE_POSITIVE_INTEGER_VALUE, 0},
{":data", IMAGE_DONT_CHECK_VALUE_TYPE, 0},
{":foreground", IMAGE_STRING_OR_NIL_VALUE, 0},
{":background", IMAGE_STRING_OR_NIL_VALUE, 0},
@@ -3191,7 +3193,7 @@ xbm_image_p (Lisp_Object object)
else
{
Lisp_Object data;
- int width, height;
+ int width, height, stride;
/* Entries for `:width', `:height' and `:data' must be present. */
if (!kw[XBM_WIDTH].count
@@ -3203,6 +3205,14 @@ xbm_image_p (Lisp_Object object)
width = XFIXNAT (kw[XBM_WIDTH].value);
height = XFIXNAT (kw[XBM_HEIGHT].value);
+ if (!kw[XBM_STRIDE].count)
+ stride = width;
+ else
+ stride = XFIXNAT (kw[XBM_STRIDE].value);
+
+ if (height > 1 && stride != (width + CHAR_BIT - 1) / CHAR_BIT * CHAR_BIT)
+ return 0;
+
/* Check type of data, and width and height against contents of
data. */
if (VECTORP (data))
@@ -3242,7 +3252,7 @@ xbm_image_p (Lisp_Object object)
}
else if (BOOL_VECTOR_P (data))
{
- if (bool_vector_size (data) / height < width)
+ if (bool_vector_size (data) / height < stride)
return 0;
}
else
--
2.20.1
next prev parent reply other threads:[~2019-06-29 7:20 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-23 7:15 bug#36337: 26.1; XBM images are sometimes not displayed correctly Markus Triska
2019-06-23 8:05 ` Pip Cet
2019-06-23 8:22 ` Markus Triska
2019-06-23 14:29 ` Eli Zaretskii
2019-06-23 16:26 ` Pip Cet
2019-06-23 16:40 ` Eli Zaretskii
2019-06-23 19:16 ` Pip Cet
2019-06-28 7:57 ` Eli Zaretskii
2019-06-28 8:29 ` Pip Cet
2019-06-28 12:43 ` Eli Zaretskii
2019-06-29 7:20 ` Pip Cet [this message]
2019-06-29 7:56 ` Eli Zaretskii
2019-06-29 8:25 ` Pip Cet
2019-06-29 9:54 ` Eli Zaretskii
2019-06-30 9:48 ` Pip Cet
2019-06-30 14:34 ` Eli Zaretskii
2019-06-30 14:53 ` Pip Cet
2019-06-30 15:15 ` Eli Zaretskii
2019-06-30 15:36 ` Pip Cet
2019-06-30 16:09 ` Eli Zaretskii
2019-06-30 17:12 ` Pip Cet
2019-06-30 17:35 ` Eli Zaretskii
2019-09-24 16:35 ` Lars Ingebrigtsen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAOqdjBfjB7OZtDczTfucAf+DsoR8eBgm5bdR6Jn6zKOm+K2k+g@mail.gmail.com \
--to=pipcet@gmail.com \
--cc=36337@debbugs.gnu.org \
--cc=eliz@gnu.org \
--cc=triska@metalevel.at \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).