Problems getting GdkRGB to work with proper colors
- From: robert_gasch peoplesoft com
- To: gtk-list redhat com
- Subject: Problems getting GdkRGB to work with proper colors
- Date: Wed, 12 May 1999 15:29:56 +0200
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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]