emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Image resizing and rotation on NS port without imagemagick


From: Alan Third
Subject: Re: Image resizing and rotation on NS port without imagemagick
Date: Sun, 8 Oct 2017 23:01:42 +0100
User-agent: Mutt/1.9.0 (2017-09-02)

On Sun, Oct 08, 2017 at 10:53:28PM +0200, Lars Ingebrigtsen wrote:
> Alan Third <address@hidden> 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]