2016-12-30 35 views
1

我要在Ubuntu中使用x lib使圖像變暗。這是我的代碼。如何在linux中使用x-window lib使圖像變暗

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; 
    } 
} 

和結果圖像是這樣的:

Image

+0

我想知道如果你正在改變伽馬值,除了你期望改變的RGB值。 img-> data包含的不止是RGB三元組,它可能包含4個字節,可能還包含alpha值。嘗試使用XGetPixel()/ XSetPixel()更改值。 – Bert

+0

這是Ubuntu機器的一個有趣的圖像選擇。我不科學的猜測是,您正在試圖操縱一個色彩絢麗的8位Pixmap。 BTW bitmap_pad不是每個像素的字節數。 –

回答

0

,在彩色模式的問題。它不是24位顏色模式 你必須使用16位顏色模式

+0

這很有趣。你的意思是24位模式? –