I have a problem displaying alpha transparency using GTK and Cairo. I am trying to display this image 1
If I do alpha blending myself, everything works.

If I pass the alpha values directly to Cairo, the shadow seems beautiful, but the glow effect is damaged.

Is this a bug in Cairo 1.14.2, or am I missing something?
GdkColor color = gtk_widget_get_style(widget)->bg[GTK_STATE_NORMAL];
Pixel color_blend
{
uint8_t(255*color.red/65535.0f)
,uint8_t(255*color.green/65535.0f)
,uint8_t(255*color.blue/65535.0f)
,255
};
while(ptr!=ptr_end)
{
auto row_src=size_t(row*factor);
auto col_src=size_t(col*factor);
auto alpha=ptr_src[row_src*width_in + col_src].v3/255.0f;
*ptr=
{
uint8_t(alpha*ptr_src[row_src*width_in + col_src].v2 + (1-alpha)*color_blend.v2)
,uint8_t(alpha*ptr_src[row_src*width_in + col_src].v1 + (1-alpha)*color_blend.v1)
,uint8_t(alpha*ptr_src[row_src*width_in + col_src].v0 + (1-alpha)*color_blend.v0)
,255
};
++col;
if(col==width_out)
{
col=0;
++row;
}
++ptr;
}
I click pixels using
auto surface=cairo_image_surface_create_for_data((uint8_t*)pixels.begin(),CAIRO_FORMAT_ARGB32,width_out,height_out,width_out*sizeof(Pixel));
cairo_set_source_surface(cr, surface, 0.5*(width-width_out), 0.0);
cairo_paint(cr);
cairo_surface_destroy(surface);
Explicitly setting the statement to CAIRO_OPERATOR_OVER does not help, the result is the same.
source
share