Attached is a first go at this. I can't work out image.el and
image-mode.el, so I'll either need a lot more time or someone more
familiar with them can have a look.
The basic problem is that image-size returns physical pixels, and we
want to calculate logical pixels. I tried a few things and failed
miserably. I tried changing image-size to return logical pixels, but
that just seemed to make everything worse, and I don't think it's a
good idea to lie about the image size.
I’m not sure what do you want to achieve here. Are you trying to automatically size bitmap images when opening them, so that it is displayed 1:1 to physical pixels? If can do something like this:(insert-image (create-image "~/d/Screen Shot 2021-02-09 at 10.11.56 AM.png" nil nil :scale (/ 1 (frame-scale-factor))))And the image inserted is displayed 1:1 to physical pixels. But :scale is not really meant for controlling pixel ratio. Maybe we should add a :pixel-ratio (or :scale-factor) attribute to control the default display size of a bitmap image?
Actually, :pixel-ratio probably isn’t a good idea. I guess we should just let the user decide what they want when inserting an image, and automatically add :scale in image-mode.
Yuan