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



Useing a buffer that's only one pixel tall? Weird. 
Well, the last parameter should be width*3, the actuall amount of memory
that one row takes up.

>           gdk_draw_rgb_image (drawable, gc, 0, y, width, 1, buf, width);
> 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.

                          _______
#********************#   / _____ \
# D. Jackson Peacock #  / /_____\ \
# pavon@gallup.net   #  |___   __ |
# ICQ 25755468       #      | |_/ /
# PO Box 2102        #      |  __/  
# Socorro, NM 87801  #  --__/ /
#********************#  \____/


On Wed, 12 May 1999 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
>           }
> 
> 
> 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
> 
> 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
> 




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