From: Alan Third <alan@idiocy.org>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: Emacs-Devel devel <emacs-devel@gnu.org>
Subject: Re: Image resizing and rotation on NS port without imagemagick
Date: Sun, 8 Oct 2017 23:01:42 +0100 [thread overview]
Message-ID: <20171008220142.GA22928@breton.holly.idiocy.org> (raw)
In-Reply-To: <m3k205pdiv.fsf@gnus.org>
On Sun, Oct 08, 2017 at 10:53:28PM +0200, Lars Ingebrigtsen wrote:
> Alan Third <alan@idiocy.org> writes:
>
> > It’s always kind of bugged me that I need imagemagick to do image
> > resizing when Cocoa and GNUstep support it natively, so I’ve finally
> > got round to implementing it.
>
> Allowing all the other image formats to support scaling and stuff would
> be very nice, but this is just for the Apple port? I think if Emacs has
> (for instance) .png scaling, it should preferably be supported across
> all architectures...
I was under the impression that imagemagick allows you to open and
scale almost any image format, so this wouldn’t be anything new.
Perhaps I misunderstood.
This should work on any platform that GNUstep runs on, though, not
just macOS. But the list of supported formats is probably very
different across platforms.
> > +- (void)setSizeFromSpec: (Lisp_Object) spec
> > +{
> > + NSSize size = [self size];
> > + Lisp_Object value;
> > + double scale = 1, aspect = size.width / size.height;
> > + double width = -1, height = -1, max_width = -1, max_height = -1;
> > +
> > + value = Fplist_get (spec, QCscale);
> > + if (NUMBERP (value))
> > + scale = XFLOATINT (value) ;
>
> [...]
>
> > + [self setSize:NSMakeSize(width, height)];
>
> (Etc.) This function seems to replicate the functionality of
> compute_image_size in image.c? Is there any reason why that couldn't
> just be reused here, too? (Perhaps the calling conventions would need
> to be tweaked a bit...)
I considered just copying and pasting it, but it would have needed a
reasonable amount of modification. The NS API uses doubles for most
sizes, while compute_image_size expects ints, so I’d have to convert
to int, do the maths, and convert back to double. It seemed as easy to
rewrite it.
--
Alan Third
next prev parent reply other threads:[~2017-10-08 22:01 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-08 20:38 Image resizing and rotation on NS port without imagemagick Alan Third
2017-10-08 20:53 ` Lars Ingebrigtsen
2017-10-08 22:01 ` Alan Third [this message]
2017-10-11 18:27 ` Charles A. Roelli
2017-10-11 19:17 ` Alan Third
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171008220142.GA22928@breton.holly.idiocy.org \
--to=alan@idiocy.org \
--cc=emacs-devel@gnu.org \
--cc=larsi@gnus.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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.