Re: Clearing drawing area window to blue



On Tue, Oct 08, 2002 at 12:49:06PM -0400, Bryan Brown wrote:
On Tue, 8 Oct 2002, Filip Van Raemdonck wrote:

* does adding a gdk_rgb_init call after gnome_init change anything?

I don't see a connection between an rgb buffer and a pixbuf.  Maybe I'm
overlooking something?  Can one use the gdk_draw_pixmap function with an
rgb buffer?

I wouldn't know actually, I was just guessing after a quick look at your
code. But you are working with colors, and gdkrgb is about color management
rather than being an rgb buffer.

However a closer look to your code showed this:

   bg_color.pixel = drawingarea1->style->white.pixel;
   bg_color.red   = 0.0*65536;
   bg_color.green = 0.375*65536;
   bg_color.blue  = 0.6875*65536;

   gdk_gc_set_background (gc_bg, &bg_color);

Havoc's book says you need to allocate a color before using it, as in
(typed in literally from the example):

  GdkColor color;

  /* Describe a pure red */
  color.red   = 65535;
  color.green = 0;
  color.blue  = 0;

  if (gdk_colormap_alloc_color (colormap, &color, FALSE, TRUE)) {
    /* success */
  }

The pixel value of the color will then automatically be filled in and can
be used to draw. Colormap should be the preexisting colormap of the
drawable you want to draw upon.

So eventually I'll need to learn how to set the
color of the pen with which the lines are to be drawn (presumably the
foreground color in some graphics context).

gdk_rgb_gc_set_foreground does this for a gc - hence the suggestion to
try setting the background with gdk_rgb_gc_set_background :-)
Note though that these functions are marked deprecated in GTK2 and I
haven't looked up yet how that part of the API is replaced.


Regards,

Filip

-- 
[ Discussion on where the correct location of traceroute is on a UNIX system ]
It is evil enough already, mentioning aix and irix failed to kill the thing.
        -- Joost Kooij



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