Exemplo n.º 1
0
static void
convert_bgra_to_rgba (guint8 const  *src,
                      guint8        *dst,
                      gint           width,
                      gint           height)
{
	guint8 const *src_pixel = src;
	guint8 * dst_pixel = dst;
	int y;

	for (y = 0; y < height; y++)
	{
		int x;

		for (x = 0; x < width; x++)
		{
			dst_pixel[0] = convert_color_channel (src_pixel[2],
							                      src_pixel[3]);
			dst_pixel[1] = convert_color_channel (src_pixel[1],
							                      src_pixel[3]);
			dst_pixel[2] = convert_color_channel (src_pixel[0],
							                      src_pixel[3]);
			dst_pixel[3] = src_pixel[3];

			dst_pixel += 4;
			src_pixel += 4;
		}
	}
}
Exemplo n.º 2
0
//void
//convert_bgra_to_rgba (guint8 const* src,
//                      guint8*       dst,
//                      int           width,
//                      int           height)
void ConvertCairoToPixbuf32(guint8* pixels, int stride, int wdh, int hgt)
{
    for( int y = 0; y<hgt; y++, pixels += stride )
    {
        guint8* p = pixels;
        for( int x = 0; x<wdh; x++, p += 4 )
        {
#ifdef HAS_LITTLE_ENDIAN
            guint8 tmp = p[0];
            p[0] = convert_color_channel(p[2], p[3]);
            p[1] = convert_color_channel(p[1], p[3]);
            p[2] = convert_color_channel(tmp,  p[3]);
#else
            guint8 tmp = p[0];
            p[0] = convert_color_channel(p[1], tmp);
            p[1] = convert_color_channel(p[2], tmp);
            p[2] = convert_color_channel(p[3], tmp);
            p[3] = tmp;
#endif
        }
    }
}