graphics: simplify 16bpp calculation
authorTom Gundersen <teg@jklm.no>
Tue, 17 Dec 2013 15:09:54 +0000 (16:09 +0100)
committerTom Gundersen <teg@jklm.no>
Tue, 17 Dec 2013 15:09:54 +0000 (16:09 +0100)
src/efi/graphics.c

index 9cb6cb4..23b5d7d 100644 (file)
@@ -252,9 +252,11 @@ EFI_STATUS bmp_to_blt(UINT8 *bmp, UINTN size,
                                 break;
 
                         case 16: {
-                                out->Red = ((in[1] >> 2) & 0x1f) << 3;
-                                out->Green = (((in[1] << 3) & 0x1f) + (in[0] >> 5)) << 3;
-                                out->Blue = ((in[0] & 0x1f)) << 3;
+                                UINT16 i = *(UINT16 *) in;
+
+                                out->Red = (i & 0x7c00) >> 7;
+                                out->Green = (i & 0x3e0) >> 2;
+                                out->Blue = (i & 0x1f) << 3;
                                 in += 1;
                                 break;
                         }