From: "Juan José García-Ripoll" <juanjose.garciaripoll@gmail.com>
To: emacs-devel@gnu.org
Subject: Re: Interest in nt_load_image?
Date: Mon, 30 Mar 2020 16:36:05 +0200 [thread overview]
Message-ID: <86lfnhsyei.fsf@csic.es> (raw)
In-Reply-To: 838sji3qhx.fsf@gnu.org
Hi,
I reply to the more technical comments below. What I sent was not meant
for production: it was the result of four hours of work and digging
through Windows manuals. I was surprised it worked so well with so
little code.
Eli Zaretskii <eliz@gnu.org> writes:
> Did you verify using these APIs will allow us to keep using the code
> which processes images at display time? Will image scaling and
> rotation still work as it does now? What about masking?
Right now all Windows code works towards creating HBITMAP images. This
code only extends that functionality, using GDI+ as an intermediary to
finally produce an HBITMAP.
The only difference is in the masking of images. The current method does
not override the masking of images. However, just like the NextStep /
OSX port, it skips building a bitmask from alpha channels.
To be more precise, the code in image.c scans the image and creates a
separate bitmask if the alpha channel contains either 0x00 or 0xFF. If
there are intermediate values of alpha (from 0x01 to 0xFE) it relies on
alpha blending from the respective library. I do not understand
why. Maybe efficency?
I am right now trying to see whether this would affect some context,
such as icons in toolbars. However, as I said, the OSX port
(ns_load_image) does not use this dual use and instead relies on the OS
for blending.
>> - At configuration time, it works just as the NextStep (NS) system,
>> disabling the use of libpng, libjpeg, libtiff and libgif when the
>> build system is Mingw.
>
> AFAIU, we will also be able to support EXIF without ImageMagick.
The Windows codec takes care of the image orientation automatically, I
believe; but I have no image in mind I can test with. However if you
want any other more sophisticated handling, such as color spaces, one
might need to use a more modern interface (Windows Image Component).
>> I have also verified that it is possible to convert all *.xpm icons
>> to *.png format and thus eliminate the need to include
>> libXpm-noX.dll. Plus, the size of the icons is reduced by 50%
>
> We aren't going to get rid of XPM icons in the distribution any time
> soon (because of other platforms), so I don't see an urgent need to do
> this.
No. I did not mean to replace the xpm icons in the sources, but instead
distribute emacs without depending on libxpm-nox, at least on Windows.
> We cannot do this at compile time, because we still try supporting
> ancient Windows versions where GDI+ is not available. Moreover, I
> think it's good to let users have the ability to decide dynamically
> which image display capability they want. It certainly makes sense to
> do that initially, while the GDI+ way is being tested in all kinds of
> real-life use cases.
Understood. I was just submitting a proof-of-concept demonstration. I
will integrate the automated configuration in configure.ac later.
However, regarding "ancient" windows machines, GDI+ was introduced in
Windows XP and Windows 2000
(https://docs.microsoft.com/en-us/windows/win32/gdiplus/-gdiplus-gdi-start). It
hardly gets older than this with working machines, does it? You would
have to go back to Windows 98 or NT 4.0, whose support ended 17 years ago.
>> +static float
>> +w32_frame_delay(GpBitmap *pBitmap, int frame)
>
> A nit: why 'float' and not 'double'? 'float' causes a minor
> inefficiency, so unless there's a good reason, I'd prefer 'double'.
The use of float comes from ns_load_image.c I guess nobody has audited
that either.
>> + if (STRINGP (specified_bg)
>> + ? FRAME_TERMINAL (f)->defined_color_hook (f,
>> + SSDATA (specified_bg),
>> + &color,
>> + false,
>> + false)
>> + : (FRAME_TERMINAL (f)->query_frame_background_color (f, &color),
>> + true))
>
> Do we really need to go through the hook mechanism here? The frame
> type is known in advance, right?
This code is not testing for frame type, but whether the background was
specified as an argument for image creation (uses the given value), or
not (it then uses ->query_frame_background). I just copied this form
image.c, which is where the determination of the PNG background color
takes place when libpng is used.
The good thing about this is that using Windows native components must
be faster than going through third-party libraries and this would allow
distributing a *-no-deps.zip with support for most standard bitmap
formats.
The bummer is that there is no simple replacement for rsvg yet, and this
library by itself pulls in libpng, libjpeg, libgif, libtiff, cairo, ...
Cheers,
--
Juan José García Ripoll
http://juanjose.garciaripoll.com
http://quinfog.hbar.es
next prev parent reply other threads:[~2020-03-30 14:36 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-29 19:33 Interest in nt_load_image? Juan José García-Ripoll
2020-03-29 21:55 ` Juan José García-Ripoll
2020-03-30 2:21 ` Eli Zaretskii
2020-03-30 7:54 ` Juan José García-Ripoll
2020-03-30 13:46 ` Eli Zaretskii
2020-03-30 14:36 ` Juan José García-Ripoll [this message]
2020-03-30 14:44 ` Juan José García-Ripoll
2020-03-30 15:50 ` Eli Zaretskii
2020-03-30 16:15 ` Juan José García-Ripoll
2020-03-30 16:37 ` Eli Zaretskii
2020-03-30 17:16 ` Stefan Monnier
2020-03-30 18:32 ` Eli Zaretskii
2020-03-30 18:41 ` Stefan Monnier
2020-03-30 18:57 ` Eli Zaretskii
2020-03-30 19:39 ` Stefan Monnier
2020-03-31 14:19 ` Eli Zaretskii
2020-03-30 18:06 ` Juan José García-Ripoll
2020-03-30 18:47 ` Eli Zaretskii
2020-03-30 18:53 ` Eli Zaretskii
2020-03-30 23:21 ` Juanma Barranquero
2020-03-31 8:01 ` Juan José García-Ripoll
2020-03-31 13:14 ` Juanma Barranquero
2020-03-31 14:50 ` Stefan Monnier
2020-03-31 15:25 ` Juanma Barranquero
2020-03-31 16:54 ` Stefan Monnier
2020-03-31 15:13 ` Juan José García-Ripoll
2020-03-31 15:28 ` Juanma Barranquero
2020-03-31 13:31 ` Eli Zaretskii
2020-03-30 15:14 ` Stefan Monnier
2020-03-30 15:57 ` Eli Zaretskii
2020-03-30 17:10 ` Stefan Monnier
2020-03-30 18:23 ` Eli Zaretskii
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=86lfnhsyei.fsf@csic.es \
--to=juanjose.garciaripoll@gmail.com \
--cc=emacs-devel@gnu.org \
/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).