Pillow-6.0.0/src/libImaging/Convert.c
/* RGBa -> RGBA conversion to remove premultiplication
   Needed for correct transforms/resizing on RGBA images */
> RGBA conversion to remove premultiplication
Needed for correct transforms/resizing on RGBA images
> RGBA conversion to remove premultiplication Needed for correct transforms / resizing on RGBA images
static void
rgba2rgbA(UINT8* out, const UINT8* in, int xsize)
{
    int x;
    unsigned int alpha;
    for (x = 0; x < xsize; x++, in+=4) {
        alpha = in[3];
        if (alpha == 255 || alpha == 0) {
            *out++ = in[0];
            *out++ = in[1];
            *out++ = in[2];
        } else {
            *out++ = CLIP8((255 * in[0]) / alpha);
            *out++ = CLIP8((255 * in[1]) / alpha);
            *out++ = CLIP8((255 * in[2]) / alpha);
        }
        *out++ = in[3];
    }
}
static void rgba2rgbA ( UINT8 * out , const UINT8 * in , int xsize ) { int x ; unsigned int alpha ; for ( x = 0 ; x < xsize ; x ++ , in += 4 ) { alpha = in [ 3 ] ; if ( alpha == 255 || alpha == 0 ) { * out ++ = in [ 0 ] ; * out ++ = in [ 1 ] ; * out ++ = in [ 2 ] ; } else { * out ++ = CLIP8 ( ( 255 * in [ 0 ] ) / alpha ) ; * out ++ = CLIP8 ( ( 255 * in [ 1 ] ) / alpha ) ; * out ++ = CLIP8 ( ( 255 * in [ 2 ] ) / alpha ) ; } * out ++ = in [ 3 ] ; } }
RGBa -> RGBA conversion to remove premultiplication
Needed for correct transforms/resizing on RGBA images
RGBa - > RGBA conversion to remove premultiplication Needed for correct transforms / resizing on RGBA images