Re: [GD-DEVEL] Distingish alphatransparent pixels in PNGs

From: Date: Wed, 21 Jul 2010 09:42:04 +0000
Subject: Re: [GD-DEVEL] Distingish alphatransparent pixels in PNGs
References: 1  Groups: php.gd.devel 
Request: Send a blank email to php-gd-devel+get-673@lists.php.net to get a copy of this message
hi, Transparent pixel as in GIF or some PNG format have nothing to do with the alpha channel (level of translucency). Transparent pixel is either opaque or transparent and is defined by only one color (color value or color index for palette images). Alpha channels (PNG only) are about level of translucency. Can you send the image please? So I can tell you which case applies. Cheers, On Tue, Jul 20, 2010 at 6:18 PM, double <ninive@gmx.at> wrote: > Hello, > > Is there a chance to distinguish alphatransparent pixels from simple > transparent pixels in PNGs? More precisely, is there a chance to check, > wheater a PNG uses alphatransparent pixels or not? > The down below testcase reports alphatransparent pixels, even if the > source file has only 1bit transparency. > > Thanks a lot > Marcus > > > > #include <stdio.h> > #include <stdlib.h> > #include <gd.h> > > int main( int argc, char *argv[] ) > { >    system( "wget -O /tmp/test.png > http://doppelbauer.name/test.png" ); > >    FILE *fp = fopen( "/tmp/test.png", "r" ); >    gdImagePtr image = gdImageCreateFromPng( fp ); >    fclose( fp ); > >    int x, y; >    for( x=0; x < gdImageSX(image); ++x ) >    { >        for( y=0; y < gdImageSY(image); ++y ) >        { >            int color = gdImageGetPixel(image, x, y); >            int alpha = gdImageAlpha(image,color); >            if( alpha == 0 || alpha == gdTransparent ) >                continue; >            printf( "PNG with 1bit alpha channel contains alphatransparent > pixel\n" ); >            return 0; >        } >    } >    return 0; > } > > > > > -- > GD Devel Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- Pierre @pierrejoye | http://blog.thepimp.net | http://www.libgd.org

« previous php.gd.devel (#673) next »