[Top][All Lists]

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

Re: Linking to ImageMagick by default

From: Alan Third
Subject: Re: Linking to ImageMagick by default
Date: Wed, 19 Dec 2018 16:03:08 +0000
User-agent: Mutt/1.10.1 (2018-07-13)

On Mon, Dec 10, 2018 at 10:09:44PM +0000, Alan Third wrote:
> If we want to go with this method I’ll have to rewrite some of the
> image handling code. At the moment we create one ‘struct image’ per
> lisp image spec, and store the image in the image cache, but this
> means if the same image is displayed twice at two different sizes we
> load it twice and store it twice. OTOH, it’s the resized version
> that’s stored, so that might save memory if we assume people are
> mostly shrinking images.
> What I’ve done in the attached would work better if we only loaded the
> image once and didn’t tie it to an image spec, so we’d only keep one
> (full size) copy in memory, and just resize it on demand. I’m unsure
> how we’d go about detangling the image data from the image spec.

I’ve continued working on this and have something mostly working, but
I’m rather stuck with the image cache.

The image spec is a lisp list that looks something like this:

    '(image :file "image.png" :format png :height 10 :width 20)

The image cache code stores this directly in the image struct and uses
it to find matching images using Fequal.

I want to strip out the properties that I’m going to use at display
time, so that I can use the same cached image for different output
sizes, while leaving other properties that I don’t know about in
place. So I’d like to store the above as

    '(image :file "image.png" :format png)

however I’m not sure how to go about filtering the list in C. I tried
a few variations on this, but they all seg fault

static Lisp_Object
get_cache_spec (Lisp_Object spec)
  Lisp_Object cache_spec, tail;

  cache_spec = Qnil;

  for (tail = XCDR (spec);
       CONSP (tail) && CONSP (XCDR (tail));
       tail = XCDR (XCDR (tail)))
      if (!EQ (XCAR (tail), Qwidth)
          && !EQ (XCAR (tail), QCheight)
          && !EQ (XCAR (tail), QCmax_width)
          && !EQ (XCAR (tail), QCmax_height)
          && !EQ (XCAR (tail), QCscale)
          && !EQ (XCAR (tail), QCmargin)
          && !EQ (XCAR (tail), QCascent)
          && !EQ (XCAR (tail), QCrelief))
        cache_spec = list3 (XCAR (tail), XCAR (XCDR (tail)), cache_spec);
  cache_spec = list2 (XCAR (spec), cache_spec);

  return cache_spec;

Any ideas or alternative approaches are appreciated.
Alan Third

reply via email to

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