Re: Converting Color to B&W



For converting from Color to B&W I used folowing technics, but unfortunatelly it does not work.

//                           PixBuf
cPixelOriginal = pbPixbufOriginal->get_Pixels();
cPixelNew = (unsigned char *) malloc (width*height*sizeof(unsigned char));
rowstride = width *1; //for BW
int bw;

for(int y=0;y<height;y++)
{
   for(int x=0;x<width;x++)
   {
/// red green blue bw = 0.3*cPixelOriginal[y*width+x]+0.59*cPixelOriginal[y*width+x]+0.11*cPixelOriginal[y*width+x]
         cPixelNew[y*width+x]=bw;
   }
}
pbPixelNew=Gdk::Pixbuf::create_from_data(cPixelNew,Gdk::COLORSPACE_RGB,false,8,width,heigh,rowstride);
But unfortunatelly it does not work.

for display image I used method Gtk::Image image2; image2.set(pbPixelNew);

regards

--
Petr Hracek, ANF DATA ECT PSS
ANF DATA spol. s r.o
a SIEMENS company
Mediahall, Bidláky 20, 639 00 Brno, Czech Republic
tel. +420 533 337 267
mailto: petr hracek siemens com




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]