Make conversion from RGB8 to RGB16 more accurate - xscreenshot - screen capture tool
 (HTM) git clone git://git.codemadness.org/xscreenshot
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 09f10196b609f477adfd6d1692508434954c3566
 (DIR) parent b0165f794fa7eee32c3c29933f60d05e122e9c4d
 (HTM) Author: z3bra <willyatmailoodotorg>
       Date:   Tue, 17 Nov 2015 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:
         M xscreenshot.c                       |       6 +++---
       
       1 file changed, 3 insertions(+), 3 deletions(-)
       ---
 (DIR) 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)