[cairo] How to render 1bpp bitmaps normally & selected (in GTK+ 3)

Mark Leisher mleisher at gmail.com
Tue Jul 12 07:48:43 PDT 2011


On 07/12/2011 02:47 AM, Maarten Bosmans wrote:
>
> Ah, right. That provides a useful bit of context.
>
> I still think you should use the correct gtk style instead of just
> inverting. Something like:
>
>     if (invert)
>         state = GTK_STATE_FLAG_SELECTED;
>     else
>         state = GTK_STATE_FLAG_NORMAL;
>
>     gtk_style_context_get_background_color(ctx,flag,&c);
>     cairo_set_source_rgb(cr,c.red,c.green,c.blue);
>     cairo_rectangle(cr, 1, 1, 13, 22);
>     cairo_fill(cr);
>
>     gtk_style_context_get_color(ctx,flag,&c);
>     cairo_set_source_rgb(cr,c.red,c.green,c.blue);
>     cairo_mask_surface(cr,s,2.0,1.0);
>

Though the color combination this produces with the default colors 
doesn't look very good, I'm going to try it under various themes to see 
if it makes sense. Thanks.
-- 
Mark Leisher


More information about the cairo mailing list