Changeset 3302 for trunk/src/gdi32/dibsect.cpp
- Timestamp:
- Apr 2, 2000, 2:24:40 PM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/gdi32/dibsect.cpp
r3292 r3302 1 /* $Id: dibsect.cpp,v 1.2 4 2000-04-01 15:05:30 sandervl Exp $ */1 /* $Id: dibsect.cpp,v 1.25 2000-04-02 12:24:40 sandervl Exp $ */ 2 2 3 3 /* … … 40 40 : bmpBits(NULL), pOS2bmp(NULL), next(NULL), bmpBitsRGB565(NULL) 41 41 { 42 int os2bmpsize;43 44 42 bmpsize = pbmi->biWidth; 45 43 /* @@@PH 98/06/07 -- high-color bitmaps don't have palette */ 46 44 47 45 this->fFlip = fFlip; 48 os2bmp size = sizeof(BITMAPINFO2);46 os2bmphdrsize = sizeof(BITMAPINFO2); 49 47 50 48 switch(pbmi->biBitCount) … … 52 50 case 1: 53 51 bmpsize = ((bmpsize + 31) & ~31) / 8; 54 os2bmp size += ((1 << pbmi->biBitCount)-1)*sizeof(RGB2);52 os2bmphdrsize += ((1 << pbmi->biBitCount)-1)*sizeof(RGB2); 55 53 break; 56 54 case 4: 57 55 bmpsize = ((bmpsize + 7) & ~7) / 2; 58 os2bmp size += ((1 << pbmi->biBitCount)-1)*sizeof(RGB2);56 os2bmphdrsize += ((1 << pbmi->biBitCount)-1)*sizeof(RGB2); 59 57 break; 60 58 case 8: 61 os2bmp size += ((1 << pbmi->biBitCount)-1)*sizeof(RGB2);59 os2bmphdrsize += ((1 << pbmi->biBitCount)-1)*sizeof(RGB2); 62 60 bmpsize = (bmpsize + 3) & ~3; 63 61 break; … … 92 90 memset(bmpBits, 0, bmpsize*pbmi->biHeight); 93 91 94 pOS2bmp = (BITMAPINFO2 *)malloc(os2bmp size);92 pOS2bmp = (BITMAPINFO2 *)malloc(os2bmphdrsize); 95 93 96 94 memset(pOS2bmp, /* set header + palette entries to zero */ 97 95 0, 98 os2bmp size);96 os2bmphdrsize); 99 97 100 98 pOS2bmp->cbFix = sizeof(BITMAPINFO2) - sizeof(RGB2); … … 238 236 { 239 237 lines = (int)lines >= 0 ? (int)lines : (int)-lines; 240 int os2bmpsize;241 238 int palsize=0; 242 239 243 240 bmpsize = pbmi->biWidth; 244 os2bmp size = sizeof(BITMAPINFO2);241 os2bmphdrsize = sizeof(BITMAPINFO2); 245 242 246 243 switch(pbmi->biBitCount) … … 249 246 bmpsize = ((bmpsize + 31) & ~31) / 8; 250 247 palsize = ((1 << pbmi->biBitCount))*sizeof(RGB2); 251 os2bmp size += palsize;248 os2bmphdrsize += palsize; 252 249 break; 253 250 case 4: 254 251 bmpsize = ((bmpsize + 7) & ~7) / 2; 255 252 palsize = ((1 << pbmi->biBitCount))*sizeof(RGB2); 256 os2bmp size += palsize;253 os2bmphdrsize += palsize; 257 254 break; 258 255 case 8: 259 256 palsize = ((1 << pbmi->biBitCount))*sizeof(RGB2); 260 os2bmp size += palsize;257 os2bmphdrsize += palsize; 261 258 bmpsize = (bmpsize + 3) & ~3; 262 259 break; … … 285 282 DosFreeMem(oldbits); 286 283 } 287 pOS2bmp = (BITMAPINFO2 *)realloc(pOS2bmp, os2bmp size);284 pOS2bmp = (BITMAPINFO2 *)realloc(pOS2bmp, os2bmphdrsize); 288 285 pOS2bmp->cbFix = sizeof(BITMAPINFO2) - sizeof(RGB2); 289 286 pOS2bmp->cx = pbmi->biWidth; … … 386 383 LONG rc; 387 384 PVOID bitmapBits = NULL; 385 int oldyinversion = 0; 388 386 389 387 HWND hwndDest = WindowFromDC(hdcDest); … … 412 410 if(nXsrc + nSrcWidth > pOS2bmp->cx) 413 411 { 414 point[3].x = pOS2bmp->cx;415 } 416 else417 point[3].x = nXsrc + nSrcWidth;412 point[3].x = pOS2bmp->cx; 413 nSrcWidth = pOS2bmp->cx - nXsrc; 414 } 415 else point[3].x = nXsrc + nSrcWidth; 418 416 419 417 if(nYsrc + nSrcHeight > pOS2bmp->cy) 420 418 { 421 point[3].y = pOS2bmp->cy; 422 } 423 else 424 point[3].y = pOS2bmp->cy - nYsrc; 425 426 427 #if 1 419 point[3].y = pOS2bmp->cy; 420 nSrcHeight = pOS2bmp->cy - nYsrc; 421 } 422 else point[3].y = pOS2bmp->cy - nYsrc; 423 424 oldyinversion = GpiQueryYInversion(hps); 428 425 if(fFlip & FLIP_VERT) 429 426 { 430 GpiEnableYInversion(hps, nDestHeight); 431 } 427 GpiEnableYInversion(hps, nDestHeight-1); 428 } 429 else GpiEnableYInversion(hps, 0); 432 430 433 431 if(fFlip & FLIP_HOR) 434 432 { 435 ULONG x; 436 x = point[0].x; 437 point[0].x = point[1].x; 438 point[1].x = x; 439 } 440 #endif 433 ULONG x; 434 x = point[0].x; 435 point[0].x = point[1].x; 436 point[1].x = x; 437 } 441 438 442 439 //SvL: Optimize this.. (don't convert entire bitmap if only a part will be blitted to the dc) … … 455 452 else rc = GpiDrawBits(hps, bmpBits, pOS2bmp, 4, &point[0], ROP_SRCCOPY, BBO_OR); 456 453 454 if(rc == GPI_OK) { 455 DIBSection *destdib = DIBSection::findHDC(hdcDest); 456 if(destdib) { 457 dprintf(("Sync destination dibsection %x (%x) (%d)", destdib->handle, hdcDest, oldyinversion)); 458 459 //todo: rgb 565 to 555 conversion if bpp == 16 460 BITMAPINFO2 *tmphdr = (BITMAPINFO2 *)malloc(destdib->os2bmphdrsize); 461 memcpy(tmphdr, destdib->pOS2bmp, destdib->os2bmphdrsize); 462 rc = GpiQueryBitmapBits(hps, nYdest, nDestHeight, destdib->GetDIBObject(), 463 tmphdr); 464 free(tmphdr); 465 if(rc != nDestHeight) { 466 DebugInt3(); 467 } 468 } 469 //restore old y inversion height 470 GpiEnableYInversion(hps, oldyinversion); 471 if(hwndDest != 0) 472 { 473 WinReleasePS(hps); 474 } 475 return(TRUE); 476 } 477 GpiEnableYInversion(hps, oldyinversion); 457 478 if(hwndDest != 0) 458 479 { 459 WinReleasePS(hps); 460 } 461 if(rc == GPI_OK) { 462 return(TRUE); 480 WinReleasePS(hps); 463 481 } 464 482 dprintf(("DIBSection::BitBlt %X (%d,%d) (%d,%d) to (%d,%d) (%d,%d) returned %d\n", hps, point[0].x, point[0].y, point[1].x, point[1].y, point[2].x, point[2].y, point[3].x, point[3].y, rc));
Note:
See TracChangeset
for help on using the changeset viewer.