GTK+ Forums Forum Index GTK+ Forums
Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Coloured pixels

 
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming
Author Message
tblue
Familiar Face


Joined: 21 Mar 2007
Posts: 13

PostPosted: Mon Sep 10, 2007 3:27 pm    Post subject: Coloured pixels Reply with quote

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);
}
Back to top
Display posts from previous:   
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming All times are GMT
Page 1 of 1

 


Powered by phpBB © 2001, 2005 phpBB Group
CodeBB 1.0 Beta 2
Protected by Anti-Spam ACP