emacs-devel
[Top][All Lists]
Advanced

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

Re: png images in tool-bar / alpha mask


From: YAMAMOTO Mitsuharu
Subject: Re: png images in tool-bar / alpha mask
Date: Sun, 06 Apr 2008 11:52:17 +0900
User-agent: Wanderlust/2.14.0 (Africa) SEMI/1.14.6 (Maruoka) FLIM/1.14.8 (Shijō) APEL/10.6 Emacs/23.0.50 (sparc-sun-solaris2.8) MULE/5.0 (SAKAKI)

>>>>> On Sat, 5 Apr 2008 11:58:15 +0100, David Reitter <address@hidden> said:

> On 4 Apr 2008, at 13:20, YAMAMOTO Mitsuharu wrote:
>> 
>> And the invalidation only takes care of the `mask' spec, but not for
>> `conversion'.

> Index: image.c
> ===================================================================
> RCS file: /sources/emacs/emacs/src/image.c,v
> retrieving revision 1.65.2.13
> diff -c -r1.65.2.13 image.c
> *** image.c   28 Mar 2008 14:57:32 -0000      1.65.2.13
> --- image.c   4 Apr 2008 15:05:11 -0000
> ***************
> *** 1135,1140 ****
> --- 1135,1146 ----
>         struct image *img = IMAGE_FROM_ID (f, id);
>         if (img->mask)
>       mask = Qt;
> + #if USE_CG_DRAWING
> +       /* Mask may be in an Alpha channel in the image data */
> +       if (img->data.ptr_val != NULL &&
> +       CGImageGetAlphaInfo(img->data.ptr_val) != kCGImageAlphaNone)
> +     mask = Qt;
> + #endif
>       }
>     else
>       error ("Invalid image specification");

This is not the only place where NULL-check of img->mask is used for
determining the existence of the image mask.  At least, xdisp.c and
macterm.c also assume that.  And add BLOCK_INPUT around
CGImageGetAlphaInfo just in case.


> ***************
> *** 1835,1840 ****
> --- 1841,1848 ----
>       {
>         Lisp_Object conversion, spec;
>         Lisp_Object mask;
> +       int release = 0;
> +       int found_p = 0;

>         spec = img->spec;

> ***************
> *** 1850,1862 ****

>         mask = image_spec_value (spec, QCheuristic_mask, NULL);
>         if (!NILP (mask))
> !     x_build_heuristic_mask (f, img, mask);
>         else
>       {
> -       int found_p;
> -
>         mask = image_spec_value (spec, QCmask, &found_p);
> !
>         if (EQ (mask, Qheuristic))
>           x_build_heuristic_mask (f, img, Qt);
>         else if (CONSP (mask)
> --- 1858,1872 ----

>         mask = image_spec_value (spec, QCheuristic_mask, NULL);
>         if (!NILP (mask))
> !     {
> !       release = 1;
> !       x_build_heuristic_mask (f, img, mask);
> !     }
>         else
>       {
>         mask = image_spec_value (spec, QCmask, &found_p);
> !       if (found_p)
> !         release = 1;
>         if (EQ (mask, Qheuristic))
>           x_build_heuristic_mask (f, img, Qt);
>         else if (CONSP (mask)
> ***************
> *** 1876,1882 ****


>         /* Should we apply an image transformation algorithm?  */
> !       conversion = image_spec_value (spec, QCconversion, NULL);
>         if (EQ (conversion, Qdisabled))
>       x_disable_image (f, img);
>         else if (EQ (conversion, Qlaplace))
> --- 1886,1895 ----


>         /* Should we apply an image transformation algorithm?  */
> !       found_p = 0;
> !       conversion = image_spec_value (spec, QCconversion, &found_p);
> !       if (found_p)
> !     release = 1;
>         if (EQ (conversion, Qdisabled))
>       x_disable_image (f, img);
>         else if (EQ (conversion, Qlaplace))
> ***************
> *** 1893,1898 ****
> --- 1906,1918 ----
>                             Fplist_get (tem, QCmatrix),
>                             Fplist_get (tem, QCcolor_adjustment));
>       }
> + #if defined (MAC_OS) && USE_CG_DRAWING
> +       if (release && img->data.ptr_val != NULL)
> +     {
> +       CGImageRelease (img->data.ptr_val);
> +       img->data.ptr_val = NULL;
> +     }
> + #endif
>       }
>   }

I would add an assignment to some variable around each call to
x_build_heuristic_mask etc. so as not to be confused with bogus
mask/conversion specs.

                                     YAMAMOTO Mitsuharu
                                address@hidden




reply via email to

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