[Gtk-sharp-list] From Gtk+ to Gtk#
amartinez@atc.ugr.es
amartinez@atc.ugr.es
Wed, 9 Mar 2005 11:30:41 +0100 (CET)
Hello,
I'd like to know how can I translate this code
(http://cybernetics.freewebspace.com/gtk/improc/node14.html) from from
Gtk+ to Gtk#. I paste the code below.
The main question is: how can I set/get the colors from every individual
pixel from a Pixbuf?
Thanks.
<code>
void draw_normal_border(GdkPixbuf *pb,int red,int green,int blue)
{
int ht,wt;
int i=0,j=0;
int flag=0;
int border=10; //10 pixels wide border.
int rowstride=0;
gchar *pixel;
ht=gdk_pixbuf_get_height(pb);
wt=gdk_pixbuf_get_width(pb);
pixel=gdk_pixbuf_get_pixels(pb);
rowstride=gdk_pixbuf_get_rowstride(pb);
for(i=0;i<ht;i++)
for(j=0;j<rowstride;j+=3)
{
flag=0;//reset flag every time.
if(i< (border))
flag=1;
else if(i > (ht-border))
flag=1;
else if(j < (border)*3)
flag=1;
else if(j > (wt-border)*3)
flag=1;
if(flag==1)
{
pixel[i*rowstride+j+0]=red;
pixel[i*rowstride+j+1]=green;
pixel[i*rowstride+j+2]=blue;
}
}
return;
}
</code>