From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Alan Third Newsgroups: gmane.emacs.devel Subject: Re: Image resizing and rotation on NS port without imagemagick Date: Sun, 8 Oct 2017 23:01:42 +0100 Message-ID: <20171008220142.GA22928@breton.holly.idiocy.org> References: <20171008203822.GA22846@breton.holly.idiocy.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1507500148 2562 195.159.176.226 (8 Oct 2017 22:02:28 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 8 Oct 2017 22:02:28 +0000 (UTC) User-Agent: Mutt/1.9.0 (2017-09-02) Cc: Emacs-Devel devel To: Lars Ingebrigtsen Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Oct 09 00:02:24 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e1JeQ-0008Og-AZ for ged-emacs-devel@m.gmane.org; Mon, 09 Oct 2017 00:02:22 +0200 Original-Received: from localhost ([::1]:55240 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1JeX-00021z-PT for ged-emacs-devel@m.gmane.org; Sun, 08 Oct 2017 18:02:29 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:46248) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1Jds-00021u-32 for emacs-devel@gnu.org; Sun, 08 Oct 2017 18:01:49 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e1Jdr-0003xi-61 for emacs-devel@gnu.org; Sun, 08 Oct 2017 18:01:48 -0400 Original-Received: from mail-wm0-x233.google.com ([2a00:1450:400c:c09::233]:45644) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e1Jdq-0003xJ-VB for emacs-devel@gnu.org; Sun, 08 Oct 2017 18:01:47 -0400 Original-Received: by mail-wm0-x233.google.com with SMTP id q124so18073834wmb.0 for ; Sun, 08 Oct 2017 15:01:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=K9TBr8odQaNRu49jKN36yxe4SEG+RGPbRwMew0Oc6nc=; b=cTPXP3AgXbJBNr2EnSyAsdrfRjbGrq4yU/jEMwaMz0rFnTkVDMG27HPL1E3iyFebZx 0bIdXBeAGHC+M1z3ZhZOswL8eQBwaADq8xeyT9WKim7toLuOcV1kIJtumZmPzpNx866g fx24VQqq0ZoyekkEu8Yvn9/9cpPayYrgTA34juXA9ULx0QTS4WsAavHCYrMqvKF4TWnE vGqqR24PxmXzqNjh3nVePEjO2RER7o/ZtwcSDHiARtilrTSldhXSa4HdlHX7LN8do2o3 jBcw0lEyQqBz7AsTnfJRQGKU20ZkrhzB5RrVkOONwDXzuQ4lWbhnoUCHRTOTuurAxdGa RJfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=K9TBr8odQaNRu49jKN36yxe4SEG+RGPbRwMew0Oc6nc=; b=FUWHYwRxGugT519xBD48sfvq426XAzAFLTNOV+ZjZFx/PkaYe/DKlgN6xD8pGMznAP 6SAWuenZYY6ynntVN1e1efJNZzBH/8sEMs6iXM/ZA5d/WnSqduCjJqRpPJRxClAKhqUF tV6JIJBUfDNrhDct0rDvBEUYNNDu0yQZa+DY3NOjM2KpgDlHVdPntIsaFG2jZWglumoX TixR+Rpbfjo7gQ+k/ydAtKayTpVaYb10uyGQeSpVNFTP4Uvl3o/eka/s6CvajC9pTlq4 ED90zuFbIKcS6gaiELf4C3j3UDzhpBkdGYmSnpVjnkuLxYb5CbIEeepZI1Xf3C87bQtg 1bpg== X-Gm-Message-State: AMCzsaVKmfb3mlHflEc3dmkQXfratzY/ppVz8OfeVWgQgk4YXhGraUBf NyzuKFptAnFNSCHRuwfvPko= X-Google-Smtp-Source: AOwi7QAYoPsoqExXL2Pa93/kJZQFxR56w/5LXZQ1y0xvZnBT8XVRTnrPHwHd7uXr4bQgM78WnsUF2w== X-Received: by 10.223.157.203 with SMTP id q11mr6950010wre.131.1507500105612; Sun, 08 Oct 2017 15:01:45 -0700 (PDT) Original-Received: from breton.holly.idiocy.org (ip6-2001-08b0-03f8-8129-7ce7-3aeb-01e4-c435.holly.idiocy.org. [2001:8b0:3f8:8129:7ce7:3aeb:1e4:c435]) by smtp.gmail.com with ESMTPSA id b3sm4024393wrg.3.2017.10.08.15.01.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 08 Oct 2017 15:01:44 -0700 (PDT) Content-Disposition: inline In-Reply-To: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::233 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 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.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:219273 Archived-At: On Sun, Oct 08, 2017 at 10:53:28PM +0200, Lars Ingebrigtsen wrote: > Alan Third 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