From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Yuan Fu Newsgroups: gmane.emacs.devel Subject: Re: "Fix" sag scaling for hidpi Date: Thu, 11 Feb 2021 12:34:50 -0500 Message-ID: References: <07D5E64D-DAD0-45B3-B272-627A73D7CBAE@gmail.com> <7308DB2C-27A5-4227-A1F9-9949EE558052@gmail.com> <87sg6alweo.fsf@gnus.org> <87pn1erewq.fsf@gmail.com> <87wnvlecrw.fsf@gnus.org> <83sg69o3av.fsf@gnu.org> <87mtwhctte.fsf@gnus.org> <9C04F72C-1BB6-4308-AD8E-4A2B471CAC4E@gmail.com> Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.60.0.2.21\)) Content-Type: multipart/alternative; boundary="Apple-Mail=_50869C90-ED61-4414-8D8E-8A89A07E5495" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="15232"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Lars Ingebrigtsen , emacs-devel , Eli Zaretskii , monnier@iro.umontreal.ca, Robert Pluim To: Alan Third Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Feb 11 18:39:07 2021 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lAFvl-0003on-SU for ged-emacs-devel@m.gmane-mx.org; Thu, 11 Feb 2021 18:39:05 +0100 Original-Received: from localhost ([::1]:47742 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lAFvk-0007yK-Pm for ged-emacs-devel@m.gmane-mx.org; Thu, 11 Feb 2021 12:39:04 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:58180) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lAFrl-0003wC-6h for emacs-devel@gnu.org; Thu, 11 Feb 2021 12:34:57 -0500 Original-Received: from mail-qt1-x82b.google.com ([2607:f8b0:4864:20::82b]:41659) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lAFri-00032S-6T; Thu, 11 Feb 2021 12:34:56 -0500 Original-Received: by mail-qt1-x82b.google.com with SMTP id z32so4727205qtd.8; Thu, 11 Feb 2021 09:34:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:message-id:mime-version:subject:date:in-reply-to:cc:to :references; bh=kvOJFqt5/HNI/GL31+KKnYr+NZyoVDgHk74bk0SlYmw=; b=TIjswPIzh3hTFHPouYaTzyczgBqpppNbb7oj6LmSxb5tQfMqUjnL3yMxRW6KReWmgc 9ZHwONYIjglF/TvCj7w66Qe/ZExqyVmj5+bnC01XynUS8q6ts0UjdfAkrqYnhpCJJ1yi BcZrhASeyz0pewBue9X4f5Hnll/AhCYKp1T/qYS/+u6Er+3dMTbdmQ8dFSUOYQcuobp8 MUgdzWfGKerHSwKao+vy3IL3THQRqiQE/g3WaCEZkOpW0euYZeVYiQLUajVFZ0/K4MMX Nn8rPPOgLnNOOuKaQDafR788v9xV/pVcLLmAOeki1URL8zLgsImnDHdPEPlWp6W+UQo8 bdxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:mime-version:subject:date :in-reply-to:cc:to:references; bh=kvOJFqt5/HNI/GL31+KKnYr+NZyoVDgHk74bk0SlYmw=; b=MK53YmTC+tTdG30R/C3m1H4E1Db3+n8MULbZ8oMtJSiepEVTnwYfOngk6+yPciAS1y eZJEPFlT54p+YENWnptKmEBHrnHHy4heyKbtoB+/IlWUEF8uPfDAc/OEGBW0bsa8AcJ4 a+7lZjAtLZQBjj0YN33za0IVX47ZgSoc1v/dXqL0kUTMTCB8tXIkOJdVThiXk2Vn5jG4 wlj5eYgOY8ryzKNLJ+JYbFpLFFMTXz+sMZ22uDTLfQuEa6Ija3byE7etqDfllYTqcTcO Leejxzw3mbPllz3EqznK4UzFv0emDQmUL3tm6BOv5gyEwa3OaeKkv63K61S9KJg4617P 31zw== X-Gm-Message-State: AOAM530TUlnMVuTbwRdqiDQwP01PvCVbrtcOoJfzsr6Ly683HpXfOpAz rc9OEc8nPPQ2CLUALFGMwCA= X-Google-Smtp-Source: ABdhPJya2GofHSUkejJ9GyY3uIh2p/zH9dBnNy6zEBlRkCVDWM925nge0fRH1PAzM5cRTanTvi+Srg== X-Received: by 2002:ac8:4b6a:: with SMTP id g10mr8658606qts.26.1613064892748; Thu, 11 Feb 2021 09:34:52 -0800 (PST) Original-Received: from ?IPv6:2601:98a:4102:3d80:41e8:5372:8b60:cc9e? ([2601:98a:4102:3d80:41e8:5372:8b60:cc9e]) by smtp.gmail.com with ESMTPSA id d14sm4094792qtc.25.2021.02.11.09.34.51 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Feb 2021 09:34:51 -0800 (PST) In-Reply-To: <9C04F72C-1BB6-4308-AD8E-4A2B471CAC4E@gmail.com> X-Mailer: Apple Mail (2.3654.60.0.2.21) Received-SPF: pass client-ip=2607:f8b0:4864:20::82b; envelope-from=casouri@gmail.com; helo=mail-qt1-x82b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:264413 Archived-At: --Apple-Mail=_50869C90-ED61-4414-8D8E-8A89A07E5495 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 >>=20 >> 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. >>=20 >> 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. >=20 > I=E2=80=99m 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: >=20 > (insert-image (create-image "~/d/Screen Shot 2021-02-09 at 10.11.56 = AM.png" > nil nil :scale (/ 1 (frame-scale-factor)))) >=20 > 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=E2=80=99t 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= --Apple-Mail=_50869C90-ED61-4414-8D8E-8A89A07E5495 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8

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=E2=80=99m 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"
          &nb= sp;            = ;    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=E2=80=99t = 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
= --Apple-Mail=_50869C90-ED61-4414-8D8E-8A89A07E5495--