xscreenshot

suckless screen capture tool
git clone git://git.2f30.org/xscreenshot.git
Log | Files | Refs | README | LICENSE

commit 09f10196b609f477adfd6d1692508434954c3566
parent b0165f794fa7eee32c3c29933f60d05e122e9c4d
Author: z3bra <willyatmailoodotorg>
Date:   Tue Nov 17 22:40:45 +0100

Make conversion from RGB8 to RGB16 more accurate

Each value has to be multiplied by 257 (65535/255), and not left-rotated
by 8 bits. Thanks FRIGN!

Diffstat:
xscreenshot.c | 6+++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/xscreenshot.c b/xscreenshot.c @@ -76,9 +76,9 @@ main(int argc, char *argv[]) for (h = 0; h < (uint32_t)img->height; h++) { for (w = 0; w < (uint32_t)img->width; w++) { tmp = XGetPixel(img, w, h); - rgba[0] = htons((tmp & img->red_mask) >> 8); - rgba[1] = htons(tmp & img->green_mask); - rgba[2] = htons((tmp & img->blue_mask) << 8); + rgba[0] = htons(((tmp & img->red_mask) >> 16) * 257); + rgba[1] = htons(((tmp & img->green_mask) >> 8) * 257); + rgba[2] = htons((tmp & img->blue_mask) * 257); rgba[3] = htons(65535); if (fwrite(&rgba, 4 * sizeof(uint16_t), 1, stdout) != 1)