Re: [newbie] How to plot to drawing_area
- From: Havoc Pennington <hp redhat com>
- To: "Individual . ." <individual mi cl>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: [newbie] How to plot to drawing_area
- Date: Sun, 2 Feb 2003 14:04:09 -0500
On Sat, Feb 01, 2003 at 06:09:48PM -0300, Individual . . wrote:
I decided it would be great if I could learn how to plot an image to a
window, pixel by pixel. Getting the image is no problem at all, since
I wrote a simple c++ class that uses libpng
(<http://pngwriter.sourceforge.net/>).
The plotting part is what is holding me up.
Well, if you were just trying to get work done instead of trying to
learn, you could do:
error = NULL;
pixbuf = gdk_pixbuf_new_from_file ("foo.png", &error);
if (error != NULL)
{
g_printerr ("error loading image: %s\n", error->message);
g_error_free (error);
exit (1);
}
image = gtk_image_new_from_pixbuf (pixbuf);
Even with a drawing area a pixbuf remains the way to go, but to draw
point by point you would do:
GdkColor color;
gc = gdk_gc_new (drawing_area->window);
gdk_color_parse (&color, "blue"); /* or set color.red/color.blue/color.green */
gdk_gc_set_rgb_fg_color (gc, &color);
gdk_draw_point (drawing_area->window, gc, x, y);
But this is far too slow for drawing a whole image.
See gtk-demo, it has examples of both of these things or similar to
them, I think.
Havoc
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]