GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Sat Apr 19, 2014 10:08 pm

All times are UTC




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Coloured pixels
PostPosted: Mon Sep 10, 2007 3:27 pm 
Offline
Familiar Face

Joined: Wed Mar 21, 2007 1:02 pm
Posts: 16
I have written a function that takes data from a buffer and displays it in grayscale on a gtk image. The image is drawn but all the pixels are black.
The code I am using to set the colours does not work.
Color.red=j;
Color.blue=j;
Color.green=j;
gdk_gc_set_rgb_fg_color(p,&Color);
Can anyone suggest how I should set the colours ?

Thanks
/TBlue.

void DrawQuarterPostview(char *buffer,GtkWidget *image)
{
int x,y,XMaximum,YMaximum,count=8;
unsigned int j,k;
GdkPixmap *pixmap;
GdkColor Color;
GdkGC *p;
XMaximum=1000*(buffer[0]-'0')+100*(buffer[1]-'0')+10*(buffer[2]-'0')+(buffer[3]-'0');
YMaximum=1000*(buffer[4]-'0')+100*(buffer[5]-'0')+10*(buffer[6]-'0')+(buffer[7]-'0');
pixmap = gdk_pixmap_new(GTK_WIDGET(mainwindow)->window, XMaximum,200, -1);
gtk_image_set_from_pixmap(GTK_IMAGE(image), pixmap, NULL);
gdk_draw_rectangle(pixmap,GTK_WIDGET(image)->style->white_gc,TRUE,0,0,XMaximum,200);
p=gdk_gc_new(image->window);
for(y=0;y<YMaximum;y++)
{
for(x=0;x<XMaximum;x+=2)
{
j=(buffer[count]&15)<<1;
k=((buffer[count++]>>4)&15)<<1;
if(j>0)
{
Color.red=j;
Color.blue=j;
Color.green=j;
gdk_color_parse (&Color, "blue");
gdk_gc_set_rgb_fg_color(p,&Color);

gdk_draw_point(pixmap,p,x+1, y);
}
if(k>0)
{
Color.red=k;
Color.blue=k;
Color.green=k;
gdk_gc_set_rgb_fg_color(p,&Color);
gdk_draw_point(pixmap,p,x, y);
}
}
}
g_object_unref(pixmap);
}


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC


Who is online

Users browsing this forum: Yahoo [Bot] and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group