[10522] in The GTK GIMP ToolKit mailing list archive
[gtk-list] Re: Drawing in GtkDrawingArea
daemon@ATHENA.MIT.EDU (Havoc Pennington)
Sun Nov 29 20:17:54 1998
Date: Sun, 29 Nov 1998 19:17:16 -0600 (CST)
From: Havoc Pennington <rhpennin@midway.uchicago.edu>
To: gtk-list@redhat.com
In-Reply-To: <3661EA17.227BD69F@jps.net>
Resent-From: gtk-list@redhat.com
Reply-To: gtk-list@redhat.com
On Sun, 29 Nov 1998, Marsel Osipov wrote:
>
> void MyClass::displayPixel(RGBColor pixel, int x, int y)
> {
> GdkColor *color;
> GdkGC * gc;
> gc = gdk_gc_new(d_area->window);
>
> color = (GdkColor *)malloc(sizeof(GdkColor));
>
color = g_new(GdkColor,1);
is a nice shortcut here (I know the FAQ does it with malloc)
> color->red = (gushort)pixel.red() * (65535/255);
> color->green = (gushort)pixel.green() * (65535/255);
> color->blue = (gushort)pixel.blue() * (65535/255);
> color->pixel = (gulong)(pixel.red()*65536 + pixel.green()*256 +
> pixel.blue());
> gdk_color_alloc(gtk_widget_get_colormap(d_area), color);
>
> gdk_gc_set_foreground(gc, color);
> gdk_gc_set_background(gc, color);
>
Looks good to me, assuming the pixel functions return the right thing
> gdk_draw_point(pixmap,
> gc,
> x,
> y);
>
In your original mail you said you were drawing to d_area->window, but
here you're drawing on 'pixmap.' Maybe that's it?
To debug, try using a different color, say gdk_color_black, and/or
drawing a big rectangle you know you can see and will be on screen.
Then you can narrow down the problem.
Havoc
--
To unsubscribe: mail -s unsubscribe gtk-list-request@redhat.com < /dev/null