Subject: Re: bug#39736: 27.0.60; wrong display of scaled checkerd pattern image

From: [email-masked]
Date: Wed, 26 Feb 2020 19:32:28 +0900

Eli Zaretskii <[email-masked]> writes:

>> > The form below temporally displays another image.
>> > The upper side is gray, the lower-left corner is black,
>> > and the lower-right corner is white.
>> > Once the text cursor gets on the image, the whole image is displayed as
>> > a gray square.
>> > 
>> > (let ((data "P1\n2 2\n01\n10")
>> >       (buf (generate-new-buffer "tmp")))
>> >   (switch-to-buffer buf)
>> >   (insert "\na")
>> >   (goto-char (point-min))
>> >   (redisplay)
>> >   (insert-image (create-image data 'pbm t :scale 16)))
>> 
>> I tried this and couldn’t replicate it, but I believe I had the patch
>> for 38394 applied, so it may be a fix. Alternatively it could be
>> related to the way the cursor is drawn on images.
>
> I didn't see any temporary display, either, FWIW.

I tested with various :scale values.

(let* ((data "P1\n2 2\n01\n10")
       (buf (generate-new-buffer "tmp"))
       (max (1+ (frame-char-height)))
       (scale 4))
  (switch-to-buffer buf)
  (while (<= scale max)
    (erase-buffer)
    (insert (format "\nscale: %g" scale))
    (goto-char (point-min))
    (redisplay)
    (insert-image (create-image data 'pbm t :scale scale))
    (insert ?_)
    (sit-for 0.5)
    (setq scale (1+ scale))))

It seems that if the image is partially displayed under '_',
lower area is painted black and white.
And the maximum value which causes temporary display seems to be
(frame-char-height).

For example, just started after emacs -Q, (frame-char-height) is 16
and :scale 17 simply displays solid gray square.
After (set-frame-font "Courier New-18"), (frame-char-height) is 27
and :scale 28 simply displays solid gray square.

The attached image shows how the square image id displayed.