Changeset 4586 for trunk/src/user32/loadres.cpp
- Timestamp:
- Nov 12, 2000, 11:58:12 AM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/user32/loadres.cpp
r4573 r4586 1 /* $Id: loadres.cpp,v 1.3 3 2000-11-09 18:15:18sandervl Exp $ */1 /* $Id: loadres.cpp,v 1.34 2000-11-12 10:58:12 sandervl Exp $ */ 2 2 3 3 /* … … 264 264 } 265 265 266 if (info->bmiHeader.biSize == sizeof(BITMAPCOREHEADER)) { 267 size = sizeof(BITMAPINFOHEADER) + 268 (sizeof (RGBTRIPLE) << ((BITMAPCOREHEADER *)info)->bcBitCount); 269 } else 266 if (info->bmiHeader.biSize == sizeof(BITMAPCOREHEADER)) 267 {//determine size of converted header 268 BITMAPCOREHEADER *core = (BITMAPCOREHEADER *)info; 269 270 int colors = 0; 271 if (core->bcBitCount <= 8) { 272 colors = (1 << core->bcBitCount); 273 } 274 size = sizeof(BITMAPINFOHEADER) + colors * sizeof(RGBQUAD); 275 } 276 else size = DIB_BitmapInfoSize(info, DIB_RGB_COLORS); 277 278 if ((hFix = GlobalAlloc(0, size)) != NULL) fix_info = (BITMAPINFO *)GlobalLock(hFix); 279 if (fix_info) 280 { 281 BYTE pix; 282 283 if (info->bmiHeader.biSize == sizeof(BITMAPCOREHEADER)) 284 {//convert old bitmap header to new format 285 ULONG colors; 286 ULONG *p, *q; 287 288 memset (fix_info, 0, sizeof (BITMAPINFOHEADER)); 289 fix_info->bmiHeader.biSize = sizeof (BITMAPINFOHEADER); 290 fix_info->bmiHeader.biWidth = ((BITMAPCOREHEADER *)info)->bcWidth; 291 fix_info->bmiHeader.biHeight = ((BITMAPCOREHEADER *)info)->bcHeight; 292 fix_info->bmiHeader.biPlanes = ((BITMAPCOREHEADER *)info)->bcPlanes; 293 fix_info->bmiHeader.biBitCount = ((BITMAPCOREHEADER *)info)->bcBitCount; 294 295 if(fix_info->bmiHeader.biBitCount <= 8) 296 { 297 p = (PULONG)((char *)info + sizeof(BITMAPCOREHEADER)); 298 q = (PULONG)((char *)fix_info + sizeof(BITMAPINFOHEADER)); 299 //convert RGBTRIPLE to RGBQUAD 300 for (colors = 1 << fix_info->bmiHeader.biBitCount; colors > 0; colors--) { 301 *q = *p & 0x00FFFFFFUL; 302 q++; 303 p = (PULONG)((char *)p + sizeof (RGBTRIPLE)); 304 } 305 } 306 } 307 else { 308 memcpy(fix_info, info, size); 309 } 310 270 311 size = DIB_BitmapInfoSize(info, DIB_RGB_COLORS); 271 312 272 if ((hFix = GlobalAlloc(0, size)) != NULL) fix_info = (BITMAPINFO *)GlobalLock(hFix);273 if (fix_info) {274 BYTE pix;275 276 if (info->bmiHeader.biSize == sizeof(BITMAPCOREHEADER)) {277 ULONG colors;278 ULONG *p, *q;279 280 memset (fix_info, 0, sizeof (BITMAPINFOHEADER));281 fix_info->bmiHeader.biSize = sizeof (BITMAPINFOHEADER);282 fix_info->bmiHeader.biWidth = ((BITMAPCOREHEADER *)info)->bcWidth;283 fix_info->bmiHeader.biHeight = ((BITMAPCOREHEADER *)info)->bcHeight;284 fix_info->bmiHeader.biPlanes = ((BITMAPCOREHEADER *)info)->bcPlanes;285 fix_info->bmiHeader.biBitCount = ((BITMAPCOREHEADER *)info)->bcBitCount;286 287 p = (PULONG)((char *)info + sizeof(BITMAPCOREHEADER));288 q = (PULONG)((char *)fix_info + sizeof(BITMAPINFOHEADER));289 for (colors = 1 << fix_info->bmiHeader.biBitCount; colors > 0; colors--) {290 *q = *p & 0x00FFFFFFUL;291 q++;292 p = (PULONG)((char *)p + sizeof (RGBTRIPLE));293 }294 } else295 memcpy(fix_info, info, size);296 297 size = DIB_BitmapInfoSize(info, DIB_RGB_COLORS);298 313 pix = *((LPBYTE)info + size); 299 314 DIB_FixColorsToLoadflags(fix_info, fuLoad, pix); 300 if ((hdc = GetDC(0)) != 0) { 315 if ((hdc = GetDC(0)) != 0) 316 { 301 317 char *bits = (char *)info + size; 302 318 if (fuLoad & LR_CREATEDIBSECTION) { … … 307 323 DIB_RGB_COLORS); 308 324 } 309 else { 310 // if(fix_info->bmiHeader.biBitCount == 1) { 311 // hbitmap = CreateBitmap(fix_info->bmiHeader.biWidth, 312 // fix_info->bmiHeader.biHeight, 313 // fix_info->bmiHeader.biPlanes, 314 // fix_info->bmiHeader.biBitCount, 315 // (PVOID)bits); 316 // } 317 // else { 318 hbitmap = CreateDIBitmap(hdc, &fix_info->bmiHeader, CBM_INIT, 319 bits, fix_info, DIB_RGB_COLORS ); 320 if(hbitmap == 0) { 321 dprintf(("LoadBitmapW: CreateDIBitmap failed!!")); 322 } 323 // } 325 else 326 { 327 #if 0 328 if(fix_info->bmiHeader.biBitCount == 1) { 329 hbitmap = CreateBitmap(fix_info->bmiHeader.biWidth, 330 fix_info->bmiHeader.biHeight, 331 fix_info->bmiHeader.biPlanes, 332 fix_info->bmiHeader.biBitCount, 333 (PVOID)bits); 334 } 335 else { 336 #endif 337 hbitmap = CreateDIBitmap(hdc, &fix_info->bmiHeader, CBM_INIT, 338 bits, fix_info, DIB_RGB_COLORS ); 339 // } 340 if(hbitmap == 0) { 341 dprintf(("LoadBitmapW: CreateDIBitmap failed!!")); 342 } 324 343 } 325 344 ReleaseDC( 0, hdc );
Note:
See TracChangeset
for help on using the changeset viewer.