comparison src/video/windows/SDL_windowsframebuffer.c @ 5184:d2652aafafbb

The format detection code works better with 555 and 565 pixel formats
author Sam Lantinga <slouken@libsdl.org>
date Fri, 04 Feb 2011 16:55:50 -0800
parents 4191af605cb0
children b530ef003506
comparison
equal deleted inserted replaced
5183:4d098d286794 5184:d2652aafafbb
58 GetDIBits(data->hdc, hbm, 0, 0, NULL, info, DIB_RGB_COLORS); 58 GetDIBits(data->hdc, hbm, 0, 0, NULL, info, DIB_RGB_COLORS);
59 DeleteObject(hbm); 59 DeleteObject(hbm);
60 60
61 *format = SDL_PIXELFORMAT_UNKNOWN; 61 *format = SDL_PIXELFORMAT_UNKNOWN;
62 if (info->bmiHeader.biCompression == BI_BITFIELDS) { 62 if (info->bmiHeader.biCompression == BI_BITFIELDS) {
63 int bpp;
63 Uint32 *masks; 64 Uint32 *masks;
64 65
66 bpp = info->bmiHeader.biPlanes * info->bmiHeader.biBitCount;
65 masks = (Uint32*)((Uint8*)info + info->bmiHeader.biSize); 67 masks = (Uint32*)((Uint8*)info + info->bmiHeader.biSize);
66 if (masks[0] == 0x00FF0000 && masks[2] == 0x000000FF) { 68 *format = SDL_MasksToPixelFormatEnum(bpp, masks[0], masks[1], masks[2], 0);
67 *format = SDL_PIXELFORMAT_RGB888;
68 } else if (masks[0] == 0x000000FF && masks[2] == 0x00FF0000) {
69 *format = SDL_PIXELFORMAT_BGR888;
70 } else if (masks[0] == 0xF800 && masks[2] == 0x001F) {
71 *format = SDL_PIXELFORMAT_RGB565;
72 } else if (masks[0] == 0x001F && masks[2] == 0xF800) {
73 *format = SDL_PIXELFORMAT_BGR565;
74 } else if (masks[0] == 0x7C00 && masks[2] == 0x001F) {
75 *format = SDL_PIXELFORMAT_RGB555;
76 } else if (masks[0] == 0x001F && masks[2] == 0x7C00) {
77 *format = SDL_PIXELFORMAT_BGR555;
78 }
79 } 69 }
80 if (*format == SDL_PIXELFORMAT_UNKNOWN) 70 if (*format == SDL_PIXELFORMAT_UNKNOWN)
81 #endif 71 #endif
82 { 72 {
83 /* We'll use RGB format for now */ 73 /* We'll use RGB format for now */