Re: possibility of export image?



oedipus schrieb:
> Hi,
> 
> is it possible with the gtkmm libary to export a Gtk::Image or
> Gtk::Drawingarea into some kind of image format, like jpg or png? If that is

"widget" is a Gtk::Image* or a Gtk::DrawingArea*:

Glib::RefPtr<Gdk::Drawable> drwbl = widget->get_window();
Glib::RefPtr<Gdk::Pixbuf> pxb;
pxb = Gdk::Pixbuf::create(drwbl, drwbl->get_colormap(),
                           0, 0, 0, 0,
                           widget->get_width(),widget->get_height());
try {
  pxb->save("Image.png", "png");
}
catch (Glib::Exception &e) {
  std::cerr << "could not save: " << e.what() << std::endl;
}

> Thank you in advance
> Alex

HTH
  --o
-- 
Oliver Nittka
ESEM Grünau GmbH & Co. KG
Dornierstraße 6, 88677 Markdorf/Germany
phone: +49 7544 9583-25, fax: +49 7544 9583-60



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