Data conversion to Image
- From: Bob Home <bobstaff snowhill com>
- To: gtk-list redhat com
- Subject: Data conversion to Image
- Date: Sat, 04 Dec 1999 02:45:15 +0000
I have a 2d dimensional grid of 8 bit weather radar data which I need to
display in a gtk_drawing_area. I've succeeded in doing this with the
following code, but I suspect there must be a more efficient way to do
this. Any suggestions would be appreciated.
There are also a few questions in the code that I'd appreciate info on.
GdkColor colmap[]=
{
// pixel red greeen blue
{0x0000,0x0000,0x0000,0x0000},
{0x0000,0x0000,0x0000,0xfffff},
:
:
{0x0000,0xffff,0x0000,0x0000}
};
// Allocate colors
for(i=0;i<numcolors;i++)
{
// Generate the pixel value, I thought that
gdk_colormap_alloc_color, was suppposed to do this
// but it only seems to work if I do it.
colmap[i].pixel = ((colmap[i].red&0xff00)<8)||
((colmap[i].green&0xff00))||
((colmap[i].blue>>8));
// Allocate color map, I'm not clear what this does or why it is
necessary on a 24 bit display, any info
// would be appreciated.
gdk_colormap_alloc_color(gdk_window_get_colormap(GTK_WIDGET(draw)->window),&comap[i],FALSE,TRUE);
}
//Plot the image one pixel at a time
for(x=0;x<XSIZE;x++)
for(y=0;y<YSIZE;y++)
{
int col = colorfunc(data[x][y]); // Select which color
from colmap to use for this pixel
// Set the foreground color
gdk_gc_set_foreground(style->dark_gc[GTK_STATE_NORMAL],colmap+col);
// Plot the point
gdk_draw_point(GTK_WIDGET(draw)->window,style->dark_gc[GTK_STATE_NORMAL],x,y);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]