You are not logged in.

#1 2011-07-09 01:16:27

drahnr
Member
Registered: 2011-03-14
Posts: 73

[SOLVED] cairo rendering png image fails

I can make cairo draw simply geometry onto a GtkDrawingArea but NOT an Image.

callback:

static gboolean
cb_event_draw (GtkWidget *obj, cairo_t *cr, gpointer data)
{
  guint width, height;
  GdkRGBA color;

  width = gtk_widget_get_allocated_width (obj);
  height = gtk_widget_get_allocated_height (obj);
  
//this one does not do anything, total fail:
/*  cairo_set_source_surface (cr, image, 10., 10.);
  cairo_fill (cr);*/

// dummy, this works:
  cairo_arc (cr, 
      width / 2., height / 2.,
      MIN (width, height) / 2.,
      0, 2. * G_PI);

  gtk_style_context_get_color (gtk_widget_get_style_context (obj),
          0,
          &color);
  gdk_cairo_set_source_rgba (cr, &color);

  cairo_fill (cr);

  
  return FALSE;
}



main:

//...
cairo_surface_t *image = cairo_image_surface_create_from_png (path);
//...

Note: I am glued to gtk+ version>=3.0 code

Thanks for any hint, this is driving me nuts...


EDIT: The code as presented here works flawlessly, the bug I had experienced came from the other end of my application, nothing gtk+/cairo related

Last edited by drahnr (2011-07-09 01:44:01)

Offline

Board footer

Powered by FluxBB