1 /* 2 * gcc /tmp/q.c && convert cat-565.png -depth 8 rgb:- | ./a.out > cat-565.h 3 */ 4 5 #include <stdio.h> 6 main()7int main() 8 { 9 int r, g, b, w, m = 0; 10 11 while (1) { 12 r = getchar(); 13 g = getchar(); 14 b = getchar(); 15 16 if (r == EOF || g == EOF || b == EOF) 17 return r == EOF; 18 19 w = (b >> 3) | ((g >> 2) << 5) | ((r >> 3) << 11); 20 printf("0x%02X, 0x%02X, ", (w >> 8) & 0xFF, w & 0xFF); 21 22 if (((++m) & 3) == 0) 23 printf("\n"); 24 } 25 } 26 27