[Top][All Lists]

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

Re: Several suggestions for image support

From: Kim F. Storm
Subject: Re: Several suggestions for image support
Date: 16 Apr 2004 16:02:52 +0200
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50

YAMAMOTO Mitsuharu <address@hidden> writes:

> >>>>> On 16 Apr 2004 02:21:11 +0200, David Kastrup <address@hidden> said:
> > PNG images support transparency.  Emacs can't make use of it.  You
> > can only have Emacs declare a particular color as transparent.  This
> > is dissatisfactory.  It should tell the PNG decoding routines Emacs'
> > background color for the purpose of transparency.
> As for PNG transparency, there was one thing that I noticed (and I've
> been forgotten to tell about it) while I was porting image support to
> Carbon Emacs.
> In png_load (image.c):
>             user_bg.red = color.red >> PNG_BG_COLOR_SHIFT;
>             user_bg.green = color.green >> PNG_BG_COLOR_SHIFT;
>             user_bg.blue = color.blue >> PNG_BG_COLOR_SHIFT;
>             fn_png_set_background (png_ptr, &user_bg,
>                                    PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0);
> I think the background color should be specified in 8-bit depth here
> (thus PNG_BG_COLOR_SHIFT should be 8 for all the platforms) because
> the 4th argument (aka need_expand) for fn_png_set_background is 0 and
> the image data has been normalized in 8-bit depth at this stage.

I can indeed see that 8-bit shift is the right setting on X.

>                                                                   You
> can observe the difference using
> http://www.w3.org/Graphics/PNG/alphatest.png.  The same thing is also
> applied to the other place (in png_load) where fn_png_set_background
> is called with its 4th argument 0.

You are right.  Shifting 8 bits here as well on X fixes transparent bg.
I will commit a fix for X shortly.

However, on W32, it seems that it explicitly scales things to 16 bits
in both cases.  I cannot test this on W32, so I cannot say what's
the right thing to do.

Here is an easy way to test it -- after downloading the image you

(insert-image (create-image "alphatest.png"))

this should result in a light blue image with nice rounded
edges; a darker blue with rough edges indicates a problem.

Kim F. Storm <address@hidden> http://www.cua.dk

reply via email to

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