Re: Displaying a scaled pixmap



TheLonelyStar wrote:
Hello dear community,

I draw a pixmap on a Gtk::DrawingArea using render_to_drawable.

What I have not found out is how to scale the pixmap while drawing!
Any hints?
Thanks!

nathan

Cairo's perfect for that...

#include <gdk/gdkcairo.h>

...

// create a Cairo context that outputs to drawingarea's window
cairo_t* cairo = gdk_cairo_create(
	drawingarea.get_window()->gobj());
	// note above needs GdkWindow* from RefPtr<Gdk::Window>, hence gobj()

gdk_cairo_set_source_pixmap(cairo,
                            pixmap->gobj(), // function needs GdkPixmap*
                            0, 0);

cairo_scale(cairo, 2.0, 2.0);

cairo_rectangle(cairo, 0, 0, pixmap->get_width(), pixmap->get_height());
cairo_fill(cairo);

cairo_destroy(cairo);



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