Re: [gtk-list] Problems getting GdkRGB to work with proper colors



I might be talking completely out my backside here, but I believe that
colours have to be in the range of 0 to 65535. Take a look at the Color
Selection section in the tutorial (section 9.12). HTH

Cheers
	Dave

On Wed, May 12, 1999 at 15:29 +0200, robert_gasch@peoplesoft.com wrote:
> 
> 
> Hi,
> 
> having gotten past my initial core dump, I've already
> managed to run into another wall. The code below
> manages to draw via GdkRGB without crashing, but the
> colors are all messed up. I can still discern the
> general outline/shape of whatever I draw, so it
> basically works, but somewhere the individial colors
> are wrong.
> 
> 
>      int       x, y, icol, i, boff,
>                lim = width*3;
>      GdkColor  *col;
>      guchar         *buf = new guchar[lim];
> 
>      for (y=0; y<height; y++)
>           {
>           for (x=0; x<width;  x++)
>                {
>                icol = some_colormap_index_by_elevation ();
>                col = d_cMap->getColor (icol);
>                boff = x*3;
>                buf[boff++] = col->red;
>                buf[boff++] = col->green;
>                buf[boff] = col->blue;
>                }
>           // draw 1 row across width of drawing area
>           gdk_draw_rgb_image (drawable, gc, 0, y, width, 1, buf, width);
>           }
> 
> 
> Clarification about gdk_draw_rgb_image:
> 
> 1) Parameter 3 (0): X-offset of starting draw
> 2) Parameter 4 (y): Y-offset of starting draw
> 3) Parameter 5 (width): The width (in pixels) of the area we want to draw to
> 4) Parameter 6 (1): The height (in pixels) of the area we want to draw to
> 5) Parameter 7 (buf): the RGB buffer, sized width*3
> 6) Parameter 8 (buf): The width (in pixels) of the area you wish to paint. If
>           you want to paint a single line across the window of the
>           screen, this should be equal to width.
> 
> Are these interpretations essentially correct? Does
> anybody have any ideas about why my colors are screwed
> up?
> 
> Thanks
> --> Robert
> 
> 
> -- 
> To unsubscribe: mail -s unsubscribe gtk-list-request@redhat.com < /dev/null
> 
> 

-- 
         Dave Swegen           | Debian 2.1 on Linux i386 2.2.3
<dave@recursive.prestel.co.uk> | PGP key available on request
      <dsw@debian.org>         | Linux: The Choice of a GNU Generation
----------------------------------------------------------------------



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