Pillow-6.0.0/src/libImaging/Convert.c
/*
 * Conversion of RGB + single transparent color to RGBA,
 * where any pixel that matches the color will have the
 * alpha channel set to 0
 */
Conversion of RGB + single transparent color to RGBA,
where any pixel that matches the color will have the
alpha channel set to 0
Conversion of RGB + single transparent color to RGBA where any pixel that matches the color will have the alpha channel set to 0
static void
rgbT2rgba(UINT8* out, int xsize, int r, int g, int b)
{
#ifdef WORDS_BIGENDIAN
    UINT32 trns = ((r & 0xff)<<24) | ((g & 0xff)<<16) | ((b & 0xff)<<8) | 0xff;
    UINT32 repl = trns & 0xffffff00;
#else
    UINT32 trns = (0xff <<24) | ((b & 0xff)<<16) | ((g & 0xff)<<8) | (r & 0xff);
    UINT32 repl = trns & 0x00ffffff;
#endif
    UINT32* tmp = (UINT32 *)out;
    int i;
    for (i=0; i < xsize; i++ ,tmp++) {
        if (tmp[0]==trns) {
            tmp[0]=repl;
        }
    }
}
static void rgbT2rgba ( UINT8 * out , int xsize , int r , int g , int b ) { #ifdef WORDS_BIGENDIAN UINT32 trns = ( ( r & 0xff ) << 24 ) | ( ( g & 0xff ) << 16 ) | ( ( b & 0xff ) << 8 ) | 0xff ; UINT32 repl = trns & 0xffffff00 ; #else UINT32 trns = ( 0xff << 24 ) | ( ( b & 0xff ) << 16 ) | ( ( g & 0xff ) << 8 ) | ( r & 0xff ) ; UINT32 repl = trns & 0x00ffffff ; #endif UINT32 * tmp = ( UINT32 * ) out ; int i ; for ( i = 0 ; i < xsize ; i ++ , tmp ++ ) { if ( tmp [ 0 ] == trns ) { tmp [ 0 ] = repl ; } } }
Conversion of RGB + single transparent color to RGBA,
 where any pixel that matches the color will have the
 alpha channel set to 0
Conversion of RGB + single transparent color to RGBA where any pixel that matches the color will have the alpha channel set to 0