Re: timestamp superimposition



On 12/28/05, Jacky Luk <lucky7456969b hotmail com> wrote:
I need to superimpose a timestamp over an image.
What is the GTK way of doing it?
Any pointers to examples? Thanks
Here's a rough example -- tiny bit incomplete.....

Well create a drawing area
widg = gtk_drawing_area_new();
put it in a scrolled area and/or size the drawing area
scroll=gtk_scrolled_window_new (NULL, NULL);
gtk_widget_set_size_request(scroll, x,y);
create and render a pixbuf
pbuf=gdk_pixbuf_new_from_file(file_name,&err);
gdk_pixbuf_render_to_drawable( pbuf, win, gc, 0,0,
                                x, y,
                                w,h, GDK_RGB_DITHER_MAX,0,0);
bunch of pango stuff
text_gc=gdk_gc_new(win);
pc=gdk_pango_context_get();
pl=pango_layout_new(pc);
pango_layout_set_text(pl,text,-1);
pango_layout_get_pixel_size(pl,&tx,&ty);
gdk_draw_layout(win,text_gc,x, y,pl);

You might want to change the text graphics context to set the
background transparent or some particular color.. foreground should be
set as well if you set background.

Also you might want to check into using the cairo stuff
http://www.cairographics.org/manual/cairo-Text.html
gdk_cairo_create()
http://beep-media-player.org/~mderezynski/cairo.txt

http://mail.gnome.org/archives/gtk-devel-list/2005-December/msg00009.html
"Deprecate GdkGC?"
http://www.mail-archive.com/gtk-app-devel-list gnome org/msg04150.html
"Looking for example to draw a simple red text on my GtkDrawable"

Mentioned on the lists before. However I haven't used them myself yet.

--
http://dmoz.org/profiles/pollei.html
http://sourceforge.net/users/stephen_pollei/
http://www.orkut.com/Profile.aspx?uid=2455954990164098214
http://stephen_pollei.home.comcast.net/



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