Changeset 4127 for trunk/src/gdi32/dibsect.cpp
- Timestamp:
- Aug 30, 2000, 8:05:25 PM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/gdi32/dibsect.cpp
r4034 r4127 1 /* $Id: dibsect.cpp,v 1.3 7 2000-08-18 18:14:57sandervl Exp $ */1 /* $Id: dibsect.cpp,v 1.38 2000-08-30 18:05:24 sandervl Exp $ */ 2 2 3 3 /* … … 41 41 : bmpBits(NULL), pOS2bmp(NULL), next(NULL), bmpBitsDblBuffer(NULL) 42 42 { 43 int palsize=0; 44 43 45 bmpsize = pbmi->biWidth; 44 46 /* @@@PH 98/06/07 -- high-color bitmaps don't have palette */ … … 50 52 { 51 53 case 1: 52 bmpsize = ((bmpsize + 31) & ~31) / 8; 53 os2bmphdrsize += ((1 << pbmi->biBitCount)-1)*sizeof(RGB2); 54 bmpsize = ((bmpsize + 31) & ~31) / 8; 55 palsize = ((1 << pbmi->biBitCount))*sizeof(RGB2); 56 os2bmphdrsize += palsize; 54 57 break; 55 58 case 4: 56 59 bmpsize = ((bmpsize + 7) & ~7) / 2; 57 os2bmphdrsize += ((1 << pbmi->biBitCount)-1)*sizeof(RGB2); 60 palsize = ((1 << pbmi->biBitCount))*sizeof(RGB2); 61 os2bmphdrsize += palsize; 58 62 break; 59 63 case 8: 60 os2bmphdrsize += ((1 << pbmi->biBitCount)-1)*sizeof(RGB2); 64 palsize = ((1 << pbmi->biBitCount))*sizeof(RGB2); 65 os2bmphdrsize += palsize; 61 66 bmpsize = (bmpsize + 3) & ~3; 62 67 break; … … 79 84 80 85 this->hSection = hSection; 86 this->dwOffset = dwOffset; 81 87 if(hSection) { 82 88 bmpBits = (char *)MapViewOfFile(hSection, FILE_MAP_ALL_ACCESS_W, 0, dwOffset, bmpsize*pbmi->biHeight); … … 130 136 dibinfo.dsBm.bmBits = bmpBits; 131 137 132 dibinfo.dshSection = h andle;138 dibinfo.dshSection = hSection; 133 139 dibinfo.dsOffset = dwOffset; 134 140 … … 136 142 { 137 143 dibinfo.dsBitfields[0] = dibinfo.dsBitfields[1] = dibinfo.dsBitfields[2] = 0; 144 if(palsize) { 145 SetDIBColorTable(0, (1 << pbmi->biBitCount), (RGBQUAD *)(pbmi+1)); 146 } 138 147 } 139 148 else { … … 305 314 306 315 dibinfo.dshSection = hSection; 307 dibinfo.dsOffset = 0; // TODO: put the correct value here (if createdibsection with file handle)316 dibinfo.dsOffset = dwOffset; 308 317 309 318 if(coloruse == DIB_PAL_COLORS || pbmi->biBitCount <= 8) … … 377 386 { 378 387 pOS2bmp->argbColor[i].fcOptions = 0; 388 #ifdef DEBUG_PALETTE 379 389 dprintf2(("Index %d : 0x%08X\n",i, *((ULONG*)(&pOS2bmp->argbColor[i])) )); 390 #endif 380 391 } 381 392 … … 547 558 } 548 559 //****************************************************************************** 560 int WIN32API GetDIBits(HDC hdc, HBITMAP hBitmap, UINT uStartScan, UINT cScanLines, 561 void *lpvBits, BITMAPINFO_W * lpbi, UINT uUsage); 562 549 563 //****************************************************************************** 550 564 void DIBSection::sync(HDC hdc, DWORD nYdest, DWORD nDestHeight) … … 555 569 dprintf(("Sync destination dibsection %x (%x)", handle, hdc)); 556 570 571 #if 0 572 BITMAPINFO_W *tmphdr = (BITMAPINFO_W *)malloc(os2bmphdrsize + sizeof(BITMAPINFO_W)); 573 tmphdr->bmiHeader.biSize = sizeof(BITMAPINFOHEADER_W); 574 GetDIBits(hdc, handle, nYdest, nDestHeight, NULL, tmphdr, 0); 575 destBuf = GetDIBObject() + nYdest*dibinfo.dsBm.bmWidthBytes; 576 rc = GetDIBits(hdc, handle, nYdest, nDestHeight, destBuf, tmphdr, 0); 577 #ifdef DEBUG_PALETTE 578 if(rc && tmphdr->bmiHeader.biBitCount <= 8) { 579 for(int i=0;i<(1<<tmphdr->bmiHeader.biBitCount);i++) 580 { 581 dprintf2(("Index %d : 0x%08X\n",i, *((ULONG*)(&tmphdr->bmiColors[i])) )); 582 } 583 } 584 #endif 585 586 #else 557 587 BITMAPINFO2 *tmphdr = (BITMAPINFO2 *)malloc(os2bmphdrsize); 558 588 memcpy(tmphdr, pOS2bmp, os2bmphdrsize); … … 576 606 rc = GpiQueryBitmapBits(hdc, nYdest, nDestHeight, destBuf, 577 607 tmphdr); 578 } 608 #ifdef DEBUG_PALETTE 609 if(rc != GPI_ALTERROR && tmphdr->cBitCount <= 8) { 610 for(int i=0;i<(1<<tmphdr->cBitCount);i++) 611 { 612 dprintf2(("Index %d : 0x%08X\n",i, *((ULONG*)(&tmphdr->argbColor[i])) )); 613 } 614 } 615 #endif 616 } 617 #endif 618 #if 0 579 619 if(dibinfo.dsBitfields[1] == 0x3E0) {//RGB 555? 580 620 dprintf(("DIBSection::sync: convert RGB 565 to RGB 555")); … … 587 627 else RGB565to555((WORD *)destBuf, (WORD *)destBuf, (nDestHeight*dibinfo.dsBm.bmWidthBytes)/sizeof(WORD)); 588 628 } 629 #endif 589 630 free(tmphdr); 590 631 if(rc != nDestHeight) { 591 632 DebugInt3(); 592 633 } 634 } 635 //****************************************************************************** 636 //manual sync if no stretching and bpp is the same 637 //WARNING: this also assumes the colortables are the same 638 //****************************************************************************** 639 void DIBSection::sync(DWORD xDst, DWORD yDst, DWORD widthDst, DWORD heightDst, PVOID bits) 640 { 641 char *srcbuf, *destbuf; 642 int linesize; 643 644 srcbuf = (char *)bits + dibinfo.dsBm.bmWidthBytes*yDst + 645 (xDst*dibinfo.dsBm.bmWidthBytes)/pOS2bmp->cx; 646 destbuf = (char *)GetDIBObject() + dibinfo.dsBm.bmWidthBytes*yDst + 647 (xDst*dibinfo.dsBm.bmWidthBytes)/pOS2bmp->cx; 648 linesize = (widthDst*dibinfo.dsBm.bmWidthBytes)/pOS2bmp->cx; 649 for(int i=0;i<heightDst;i++) { 650 memcpy(destbuf, srcbuf, linesize); 651 destbuf += dibinfo.dsBm.bmWidthBytes; 652 srcbuf += linesize; 653 } 593 654 } 594 655 //******************************************************************************
Note:
See TracChangeset
for help on using the changeset viewer.