Re: Printing images



On 11/2/07, Igor Gorbounov <igorbounov topazelectro ru> wrote:
> Jonathon Jongsma пишет:
> > [...]
> > And use this function to draw into your DrawingArea in the expose
> > event and also use the same function to draw into your print context.
> >
> >
> Is there any example of printing a picture using print context?
> I just have no idea of how it could be done.
>     Igor Gorbounov
>

I don't know of any gtkmm examples for this, but the basic concepts
are fairly simple:

in your 'draw page' handler, (e.g. on_draw_page()), get the cairo
context from the Print context (e.g. context->get_cairo_context()).
Then draw the image into the cairo context.  You can use any of the
cairo drawing operators (move_to(), line_to(), fill(), etc), or if you
want to print an image from file, you can create a Cairo::ImageSurface
from a png (Cairo::ImageSurface::create_from_png()) and paint this
into the cairo context.  If you want to print a Gdk::Pixbuf, you can
look at the function "eog_window_print_draw_page()" for inspiration.
it should translate to gtkmm/cairomm fairly easily:
http://svn.gnome.org/viewvc/eog/trunk/src/eog-window.c?revision=4191&view=markup

Hope that helps
-- 
jonner


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