c++ - CAIRO_OPERATOR_OVER not working as expected -


the following code should create 2 overlapping rectangles (see operator guide, alpha values ignored:

resulting image:

enter image description here

code:

cairo_surface_t *surface; cairo_t *cr; int stride = cairo_format_stride_for_width(cairo_format_argb32,width); unsigned char *buffer = new unsigned char[stride * height]; surface = cairo_image_surface_create_for_data(buffer,cairo_format_argb32,width,height,stride); cr = cairo_create (surface);  cairo_set_source_rgb(cr, 0, 0, 0); cairo_rectangle (cr,0,0,width,height); cairo_fill (cr);  cairo_set_source_rgba(cr,0xff,0,0,0xff); cairo_set_line_width (cr, 3); cairo_rectangle(cr,width/2,height/2,width/3,height/3); cairo_fill(cr);  cairo_set_operator(cr,cairo_operator_over);  cairo_set_source_rgba(cr,0,0,0xff,0x7f); cairo_set_line_width (cr,3); cairo_rectangle(cr,width/3,height/3,width/3,height/3); cairo_fill(cr);  cairo_surface_write_to_png(surface,"c:\\temp\\test.png");  delete[] buffer; cairo_destroy(cr); cairo_surface_destroy(surface); 

do know problem might be?

my problem was, each rgba component floating point value 0 1, not byte value 0 0xff. therefore alpha information provided wrong.


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -