From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andy Wingo Subject: Re: [PATCH] system: grub: Convert grub background using rsvg-convert Date: Mon, 31 Aug 2015 10:57:17 +0200 Message-ID: <87zj17vnrm.fsf@igalia.com> References: <87egitx3r7.fsf@netris.org> <87twrkwhs9.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:42956) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWKu6-0005bO-JA for guix-devel@gnu.org; Mon, 31 Aug 2015 04:57:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZWKu2-0001Da-J0 for guix-devel@gnu.org; Mon, 31 Aug 2015 04:57:26 -0400 In-Reply-To: ("Luis Felipe =?utf-8?Q?L=C3=B3pez?= Acevedo"'s message of "Fri, 28 Aug 2015 12:15:49 -0500") List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org To: Luis Felipe =?utf-8?Q?L=C3=B3pez?= Acevedo Cc: guix-devel@gnu.org On Fri 28 Aug 2015 19:15, Luis Felipe L=C3=B3pez Acevedo writes: > Modifying the document background does not affect the design at all, > because we are using the dark rectangle on top of it as the background > of the image, so it doesn't matter what the background of the document > is. > > Could it be that rsvg-convert is complaining about transparency in the > page/document background and not about the transparency of the > checkerboard pattern in the "Background" layer? Because it is not > complaining about the transparency in the layer that contains the logo > (which has transparency as well), is it? We could use guile-cairo / guile-rsvg to convert, fwiw. Better to do that than to cause our graphics people to modify the image. (use-modules (rsvg) (cairo)) (define (->int x) (inexact->exact (ceiling x))) (define (render-to-png in-svg out-png) (let ((svg (rsvg-handle-new-from-file in-svg))) (call-with-values (lambda () (rsvg-handle-get-dimensions svg)) (lambda (width height em ex) (let* ((surf (cairo-image-surface-create 'argb32 (->int width) (->int height))) (cr (cairo-create surf))) (rsvg-handle-render-cairo svg cr) (cairo-surface-flush surf) (cairo-surface-write-to-png (cairo-get-target cr) out-png)))))) That will render a png with the svg's natural pixel dimensions. You can use the png as is, or instead of rendering to a png you could use "surf" as a source surface for other paint operations, for example if you want to down-scale the image nicely. Here's an example, for a suitable definition of create-image-surface and scale-dimensions: (call-with-values (lambda () (create-image-surface filename width height)) (lambda (surface swidth sheight) (if surface (call-with-values (lambda () (scale-dimensions (/ swidth 1.0 shei= ght))) (lambda (x0 y0 width height) (cairo-save cr) (cairo-translate cr x0 y0) (cairo-scale cr (/ width swidth) (/ height sheight)) (cairo-set-source-surface cr surface 0 0) (cairo-pattern-set-filter (cairo-get-source cr) 'best) (cairo-rectangle cr 0 0 swidth sheight) (cairo-fill cr) (cairo-restore cr) (values width height))) (values 0 0)))) FWIW :) Cheers, Andy