Gdk Pixbuf and Monochrome images
- From: Mohit Kumar <mohit kumar gmail com>
- To: gtk-list gnome org
- Subject: Gdk Pixbuf and Monochrome images
- Date: Tue, 27 Sep 2005 11:49:42 +0530
Hi All,
I am trying to display a monochrome image in a GdkPixbuf. I have the
monochrome data in memory and to use it for the call
"gdk_pixbuf_new_from_data" i need to convert into RGB Pixels. Hence
where ever I find 1 in bit, it is replaced with 3 bytes woth 0xFF and
whereever I find a 0 in a bit, it is replaces with 3 bytes of 0x00.
However, I am still unable to get the rendered image correctly. The following is the piece of code:
for(int i=0;i<count;i++)
{
printf("%d",(int)tempBuffer[i]);
guchar bitShift = 1 << 7;
for(int shift=0;shift<8;shift++)
{
guchar bit = bitShift >>
shift;
if(bit & tempBuffer[i])
buf[i*24 +
shift*3] = buf[i*24 + shift*3 + 1] = buf[i*24 + shift*3 + 2] = 0x00;
else
buf[i*24 +
shift*3] = buf[i*24 + shift*3 +1] = buf[i*24 + shift*3 + 2] = 0xFF;
}
}
Could anyone help me with where am I going wrong?
Moreover, I find this method very inefficient as there is no use for
the user to load a monochrome image, I am using the same amount of
memory anyways. Is there a better alternative to this?
Thanks,
Mohit
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]