I am going to darken image using x lib in Ubuntu. Here is my code.
XImage* getCorrectedImage(Pixmap p){
int buflen, i;
XImage* img = XGetImage(g_display, p, 0, 0, g_width, g_height, AllPlanes, ZPixmap);
buflen = img->width * img->height * img->bitmap_pad / 8;
for(i = 0; i < buflen; i++){
img->data[i] /= 2;
}
}
And the result image is like this:
It is problem in color mode. it is not 24bit color mode you have to use 16bit color mode