copying a pixmap



I need to copy a pixmap so I can annotate it before for
converting it to a png file without permanently adding
the annotatation to the pixmap I'm using for off-screen
drawing of my drawing area.

I figured out a way to do it, but I'm guessing it's not the right
way.  Here's what I did:

GdkPixmap *pixmap;  // the destination of my pixmap copy
pixmap= gdk_pixmap_new(darea_->window, xsize_, ysize_, -1);
gdk_draw_pixmap(pixmap, darea_->style->fg_gc[GTK_WIDGET_STATE (darea_)],
pixmapToBeCopied, 0, 0, 0, 0, xsize_, ysize_);
cr_ = gdk_cairo_create(pixmap);
// annotate the copied pixmap here with cairo as needed
//...
cairo_destroy(cr_);

// convert the annotated pixmap to a png file
GdkPixbuf *pixbuf = gdk_pixbuf_get_from_drawable(NULL, pixmap, NULL, 0, 0, 0, 0, -1, -1);
gdk_pixbuf_save (pixbuf, fname, "png", NULL, NULL);
g_object_unref(pixbuf);
g_object_unref(pixmap);


Is there a better way to do what I'm trying to do?

Thanks,

          David

_________________________________________________________________
Valentine?s Day -- Shop for gifts that spell L-O-V-E at MSN Shopping http://shopping.msn.com/content/shp/?ctId=8323,ptnrid=37,ptnrdata=24095&tcode=wlmtagline




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]