Changeset 8871 for trunk/src/gdi32/dibitmap.cpp
- Timestamp:
- Jul 15, 2002, 12:02:30 PM (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/gdi32/dibitmap.cpp
r7713 r8871 1 /* $Id: dibitmap.cpp,v 1.3 0 2001-12-30 22:19:05sandervl Exp $ */1 /* $Id: dibitmap.cpp,v 1.31 2002-07-15 10:02:28 sandervl Exp $ */ 2 2 3 3 /* … … 20 20 #include "rgbcvt.h" 21 21 #include <stats.h> 22 #include "oslibgpi.h" 23 #include <objhandle.h> 22 24 23 25 #define DBG_LOCALLOG DBG_dibitmap … … 68 70 } 69 71 rc = CreateDIBitmap(hdc, lpbmih, fdwInit, newbits, lpbmi, fuUsage); 70 free( newbits );72 free( newbits ); 71 73 } 72 74 … … 93 95 case 15: 94 96 case 16: //Default if BI_BITFIELDS not set is RGB 555 95 bitfields[0] = (lpbmih->biCompression == BI_BITFIELDS) ? *(DWORD *)lpbmi->bmiColors : 0x7c00;96 bitfields[1] = (lpbmih->biCompression == BI_BITFIELDS) ? *((DWORD *)lpbmi->bmiColors + 1) : 0x03e0;97 bitfields[2] = (lpbmih->biCompression == BI_BITFIELDS) ? *((DWORD *)lpbmi->bmiColors + 2) : 0x001f;97 bitfields[0] = (lpbmih->biCompression == BI_BITFIELDS) ? *(DWORD *)lpbmi->bmiColors : DEFAULT_16BPP_RED_MASK; 98 bitfields[1] = (lpbmih->biCompression == BI_BITFIELDS) ? *((DWORD *)lpbmi->bmiColors + 1) : DEFAULT_16BPP_GREEN_MASK; 99 bitfields[2] = (lpbmih->biCompression == BI_BITFIELDS) ? *((DWORD *)lpbmi->bmiColors + 2) : DEFAULT_16BPP_BLUE_MASK; 98 100 break; 99 101 case 24: 100 102 case 32: 101 bitfields[0] = (lpbmih->biCompression == BI_BITFIELDS) ? *(DWORD *)lpbmi->bmiColors : 0xff0000;102 bitfields[1] = (lpbmih->biCompression == BI_BITFIELDS) ? *((DWORD *)lpbmi->bmiColors + 1) : 0xff00;103 bitfields[2] = (lpbmih->biCompression == BI_BITFIELDS) ? *((DWORD *)lpbmi->bmiColors + 2) : 0xff;103 bitfields[0] = (lpbmih->biCompression == BI_BITFIELDS) ? *(DWORD *)lpbmi->bmiColors : DEFAULT_24BPP_RED_MASK; 104 bitfields[1] = (lpbmih->biCompression == BI_BITFIELDS) ? *((DWORD *)lpbmi->bmiColors + 1) : DEFAULT_24BPP_GREEN_MASK; 105 bitfields[2] = (lpbmih->biCompression == BI_BITFIELDS) ? *((DWORD *)lpbmi->bmiColors + 2) : DEFAULT_24BPP_BLUE_MASK; 104 106 break; 105 107 default: … … 109 111 break; 110 112 } 111 if(bitfields[1] == 0x3E0&& lpbInit && fdwInit == CBM_INIT)113 if(bitfields[1] == RGB555_GREEN_MASK && lpbInit && fdwInit == CBM_INIT) 112 114 {//RGB 555? 113 115 dprintf(("RGB 555->565 conversion required %x %x %x", bitfields[0], bitfields[1], bitfields[2])); … … 132 134 ((BITMAPINFOHEADER *)lpbmih)->biBitCount = biBitCount; 133 135 134 if(rc) STATS_CreateDIBitmap(rc, hdc, lpbmih, fdwInit, lpbInit, lpbmi, fuUsage); 136 if(rc) { 137 STATS_CreateDIBitmap(rc, hdc, lpbmih, fdwInit, lpbInit, lpbmi, fuUsage); 138 #ifdef NEW_GDIHANDLES 139 if(bitfields[1] == RGB565_GREEN_MASK) { 140 //mark bitmap as RGB565 141 dprintf(("RGB565 bitmap")); 142 ObjSetHandleFlag(rc, OBJHANDLE_FLAG_BMP_RGB565, TRUE); 143 } 144 #endif 145 } 135 146 136 147 return rc; … … 141 152 { 142 153 HBITMAP hBitmap; 154 #ifdef NEW_GDIHANDLES 155 pDCData pHps; 156 157 pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc); 158 if(!pHps) 159 { 160 SetLastError(ERROR_INVALID_HANDLE); 161 return 0; 162 } 163 #endif 143 164 144 165 hBitmap = O32_CreateCompatibleBitmap(hdc, nWidth, nHeight); 145 166 dprintf(("GDI32: CreateCompatibleBitmap %x (%d,%d) returned %x", hdc, nWidth, nHeight, hBitmap)); 146 if(hBitmap) STATS_CreateCompatibleBitmap(hBitmap,hdc, nWidth, nHeight); 167 if(hBitmap) { 168 STATS_CreateCompatibleBitmap(hBitmap,hdc, nWidth, nHeight); 169 #ifdef NEW_GDIHANDLES 170 if(pHps->hwnd == 1) { //1 == HWND_DESKTOP 171 dprintf(("Screen compatible bitmap")); 172 ObjSetHandleFlag(hBitmap, OBJHANDLE_FLAG_BMP_SCREEN_COMPATIBLE, 1); 173 } 174 #endif 175 } 147 176 148 177 return hBitmap; … … 153 182 HBITMAP WIN32API CreateDiscardableBitmap(HDC hDC, int nWidth, int nHeight) 154 183 { 155 dprintf(("GDI32: CreateDisardableBitmap \n"));184 dprintf(("GDI32: CreateDisardableBitmap")); 156 185 return CreateCompatibleBitmap(hDC, nWidth, nHeight); 157 186 } … … 161 190 UINT cBitsPerPel, const void *lpvBits) 162 191 { 163 HBITMAP hBitmap;192 HBITMAP hBitmap; 164 193 165 194 hBitmap = O32_CreateBitmap(nWidth, nHeight, cPlanes, cBitsPerPel, lpvBits); … … 187 216 VOID **ppvBits, HANDLE hSection, DWORD dwOffset) 188 217 { 189 HBITMAP res = 0;190 BOOL fFlip = 0;191 int iHeight, iWidth;192 BOOL fCreateDC = FALSE;193 194 dprintf(("GDI32: CreateDIBSection %x %x %x %x %x %d", hdc, pbmi, iUsage, ppvBits, hSection, dwOffset));218 HBITMAP res = 0; 219 BOOL fFlip = 0; 220 int iHeight, iWidth; 221 BOOL fCreateDC = FALSE; 222 223 dprintf(("GDI32: CreateDIBSection %x %x %x %x %x %d", hdc, pbmi, iUsage, ppvBits, hSection, dwOffset)); 195 224 196 225 //SvL: 13-9-98: StarCraft uses bitmap with negative height … … 368 397 case 15: 369 398 case 16: //RGB 565 370 ((DWORD*)(lpbi->bmiColors))[0] = 0x7c00; 371 ((DWORD*)(lpbi->bmiColors))[1] = 0x03E0; 372 ((DWORD*)(lpbi->bmiColors))[2] = 0x001F; 373 break; 399 { 400 #ifdef NEW_GDIHANDLES 401 DWORD dwFlags; 402 403 dwFlags = ObjQueryHandleFlags(hBitmap); 404 if(dwFlags & (OBJHANDLE_FLAG_BMP_SCREEN_COMPATIBLE|OBJHANDLE_FLAG_BMP_RGB565)) { 405 ((DWORD*)(lpbi->bmiColors))[0] = RGB565_RED_MASK; 406 ((DWORD*)(lpbi->bmiColors))[1] = RGB565_GREEN_MASK; 407 ((DWORD*)(lpbi->bmiColors))[2] = RGB565_BLUE_MASK; 408 } 409 else { 410 ((DWORD*)(lpbi->bmiColors))[0] = RGB555_RED_MASK; 411 ((DWORD*)(lpbi->bmiColors))[1] = RGB555_GREEN_MASK; 412 ((DWORD*)(lpbi->bmiColors))[2] = RGB555_BLUE_MASK; 413 } 414 break; 415 #else 416 ((DWORD*)(lpbi->bmiColors))[0] = RGB555_RED_MASK; 417 ((DWORD*)(lpbi->bmiColors))[1] = RGB555_GREEN_MASK; 418 ((DWORD*)(lpbi->bmiColors))[2] = RGB555_BLUE_MASK; 419 #endif 420 } 374 421 case 24: 375 422 case 32: 376 ((DWORD*)(lpbi->bmiColors))[0] = 0xFF0000; 377 ((DWORD*)(lpbi->bmiColors))[1] = 0x00FF00; 378 ((DWORD*)(lpbi->bmiColors))[2] = 0x0000FF; 379 break; 380 } 381 } 382 if(nrlines && lpvBits && lpbi->bmiHeader.biBitCount == 16 && ((DWORD*)(lpbi->bmiColors))[1] == 0x3E0) 423 ((DWORD*)(lpbi->bmiColors))[0] = DEFAULT_24BPP_RED_MASK; 424 ((DWORD*)(lpbi->bmiColors))[1] = DEFAULT_24BPP_GREEN_MASK; 425 ((DWORD*)(lpbi->bmiColors))[2] = DEFAULT_24BPP_BLUE_MASK; 426 break; 427 } 428 if(lpbi->bmiHeader.biCompression == BI_RGB && lpbi->bmiHeader.biBitCount > 8) { 429 lpbi->bmiHeader.biCompression = BI_BITFIELDS; 430 dprintf(("BI_BITFIELDS: %x %x %x", ((DWORD*)(lpbi->bmiColors))[0], ((DWORD*)(lpbi->bmiColors))[1], ((DWORD*)(lpbi->bmiColors))[2])); 431 } 432 } 433 if(nrlines && lpvBits && lpbi->bmiHeader.biBitCount == 16 && ((DWORD*)(lpbi->bmiColors))[1] == RGB555_GREEN_MASK) 383 434 {//RGB 555? 384 435 dprintf(("RGB 565->555 conversion required")); … … 457 508 case 15: 458 509 case 16: //Default if BI_BITFIELDS not set is RGB 555 459 bitfields[0] = (pBitmapInfo->bmiHeader.biCompression == BI_BITFIELDS) ? *(DWORD *)pBitmapInfo->bmiColors : 0x7c00;460 bitfields[1] = (pBitmapInfo->bmiHeader.biCompression == BI_BITFIELDS) ? *((DWORD *)pBitmapInfo->bmiColors + 1) : 0x03e0;461 bitfields[2] = (pBitmapInfo->bmiHeader.biCompression == BI_BITFIELDS) ? *((DWORD *)pBitmapInfo->bmiColors + 2) : 0x001f;510 bitfields[0] = (pBitmapInfo->bmiHeader.biCompression == BI_BITFIELDS) ? *(DWORD *)pBitmapInfo->bmiColors : DEFAULT_16BPP_RED_MASK; 511 bitfields[1] = (pBitmapInfo->bmiHeader.biCompression == BI_BITFIELDS) ? *((DWORD *)pBitmapInfo->bmiColors + 1) : DEFAULT_16BPP_GREEN_MASK; 512 bitfields[2] = (pBitmapInfo->bmiHeader.biCompression == BI_BITFIELDS) ? *((DWORD *)pBitmapInfo->bmiColors + 2) : DEFAULT_16BPP_BLUE_MASK; 462 513 break; 463 514 464 515 case 24: 465 516 case 32: 466 bitfields[0] = (pBitmapInfo->bmiHeader.biCompression == BI_BITFIELDS) ? *(DWORD *)pBitmapInfo->bmiColors : 0xff0000;467 bitfields[1] = (pBitmapInfo->bmiHeader.biCompression == BI_BITFIELDS) ? *((DWORD *)pBitmapInfo->bmiColors + 1) : 0xff00;468 bitfields[2] = (pBitmapInfo->bmiHeader.biCompression == BI_BITFIELDS) ? *((DWORD *)pBitmapInfo->bmiColors + 2) : 0xff;517 bitfields[0] = (pBitmapInfo->bmiHeader.biCompression == BI_BITFIELDS) ? *(DWORD *)pBitmapInfo->bmiColors : DEFAULT_24BPP_RED_MASK; 518 bitfields[1] = (pBitmapInfo->bmiHeader.biCompression == BI_BITFIELDS) ? *((DWORD *)pBitmapInfo->bmiColors + 1) : DEFAULT_24BPP_GREEN_MASK; 519 bitfields[2] = (pBitmapInfo->bmiHeader.biCompression == BI_BITFIELDS) ? *((DWORD *)pBitmapInfo->bmiColors + 2) : DEFAULT_24BPP_BLUE_MASK; 469 520 break; 470 521 default: … … 474 525 break; 475 526 } 476 if(pBits && bitfields[1] == 0x3E0)527 if(pBits && bitfields[1] == RGB555_GREEN_MASK) 477 528 {//RGB 555? 478 529 dprintf(("RGB 555->565 conversion required %x %x %x", bitfields[0], bitfields[1], bitfields[2]));
Note:
See TracChangeset
for help on using the changeset viewer.