From: <kr_...@us...> - 2003-02-01 08:58:59
|
Update of /cvsroot/htoolkit/port/src/cbits/Win32 In directory sc8-pr-cvs1:/tmp/cvs-serv9137/port/src/cbits/Win32 Modified Files: Bitmap.c Log Message: Bug fix. The writeBitmap and drawBitmap was buggy when the bitmap is resized Index: Bitmap.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/Win32/Bitmap.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Bitmap.c 31 Jan 2003 23:25:37 -0000 1.2 --- Bitmap.c 1 Feb 2003 08:58:56 -0000 1.3 *************** *** 305,311 **** canvas->hDC = CreateCompatibleDC(hScreenDC); ! DeleteDC(hScreenDC); ! SelectObject(canvas->hDC, bitmap->hBitmap); return canvas; --- 305,331 ---- canvas->hDC = CreateCompatibleDC(hScreenDC); ! if (bitmap->destsize.cx != bitmap->sourcesize.cx || bitmap->destsize.cy != bitmap->sourcesize.cy) ! { ! HDC hSourceDC; ! HBITMAP hBitmap; ! hBitmap = CreateCompatibleBitmap(hScreenDC, bitmap->destsize.cx, bitmap->destsize.cy); ! SelectObject(canvas->hDC, hBitmap); ! ! hSourceDC = CreateCompatibleDC(hScreenDC); ! SelectObject(hSourceDC, bitmap->hBitmap); ! ! StretchBlt(canvas->hDC, 0, 0, bitmap->destsize.cx, bitmap->destsize.cy, hSourceDC, 0, 0, bitmap->sourcesize.cx, bitmap->sourcesize.cy, SRCCOPY); ! ! DeleteDC(hSourceDC); ! ! DeleteObject(bitmap->hBitmap); ! bitmap->hBitmap = hBitmap; ! bitmap->sourcesize = bitmap->destsize; ! } ! else ! SelectObject(canvas->hDC, bitmap->hBitmap); ! ! DeleteDC(hScreenDC); return canvas; *************** *** 353,356 **** --- 373,378 ---- { HDC hScreenDC; + HBITMAP hBitmap; + BOOL bFlag; hScreenDC = CreateDC("DISPLAY",NULL,NULL,NULL); *************** *** 358,361 **** --- 380,407 ---- return 1; + if (bitmap->destsize.cx != bitmap->sourcesize.cx || bitmap->destsize.cy != bitmap->sourcesize.cy) + { + HDC hSourceDC, hDestDC; + + hDestDC = CreateCompatibleDC(hScreenDC); + hBitmap = CreateCompatibleBitmap(hScreenDC, bitmap->destsize.cx, bitmap->destsize.cy); + SelectObject(hDestDC, hBitmap); + + hSourceDC = CreateCompatibleDC(hScreenDC); + SelectObject(hSourceDC, bitmap->hBitmap); + + StretchBlt(hDestDC, 0, 0, bitmap->destsize.cx, bitmap->destsize.cy, hSourceDC, 0, 0, bitmap->sourcesize.cx, bitmap->sourcesize.cy, SRCCOPY); + + DeleteDC(hDestDC); + DeleteDC(hSourceDC); + + bFlag = TRUE; + } + else + { + hBitmap = bitmap->hBitmap; + bFlag = FALSE; + } + if (initGdiPlus()) { *************** *** 376,379 **** --- 422,426 ---- rfree(lpwBuffer); DeleteDC(hScreenDC); + if (bFlag) DeleteObject(hBitmap); return 1; } *************** *** 384,387 **** --- 431,435 ---- rfree(lpwBuffer); DeleteDC(hScreenDC); + if (bFlag) DeleteObject(hBitmap); return 2; } *************** *** 391,394 **** --- 439,443 ---- rfree(lpwBuffer); DeleteDC(hScreenDC); + if (bFlag) DeleteObject(hBitmap); return 1; } *************** *** 396,403 **** gpBitmap = NULL; ! if (GdipCreateBitmapFromHBITMAP(bitmap->hBitmap, hPal, &gpBitmap) != 0 || !gpBitmap) { rfree(lpwBuffer); DeleteDC(hScreenDC); return 1; } --- 445,453 ---- gpBitmap = NULL; ! if (GdipCreateBitmapFromHBITMAP(hBitmap, hPal, &gpBitmap) != 0 || !gpBitmap) { rfree(lpwBuffer); DeleteDC(hScreenDC); + if (bFlag) DeleteObject(hBitmap); return 1; } *************** *** 408,411 **** --- 458,462 ---- GdipDisposeImage(gpBitmap); DeleteDC(hScreenDC); + if (bFlag) DeleteObject(hBitmap); return 3; } *************** *** 428,431 **** --- 479,483 ---- { DeleteDC(hScreenDC); + if (bFlag) DeleteObject(hBitmap); return 2; } *************** *** 436,442 **** bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); bmi.bmiHeader.biBitCount = 0; // dont get the color table ! if (!GetDIBits(hScreenDC, bitmap->hBitmap, 0, 0, NULL, &bmi, DIB_RGB_COLORS)) { DeleteDC(hScreenDC); return 1; } --- 488,495 ---- bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); bmi.bmiHeader.biBitCount = 0; // dont get the color table ! if (!GetDIBits(hScreenDC, hBitmap, 0, 0, NULL, &bmi, DIB_RGB_COLORS)) { DeleteDC(hScreenDC); + if (bFlag) DeleteObject(hBitmap); return 1; } *************** *** 476,483 **** // Assume that the hDC is the DC where the bitmap would have been selected // if indeed it has been selected ! if (!GetDIBits(hScreenDC, bitmap->hBitmap, 0, pBMI->bmiHeader.biHeight, pBits, pBMI, DIB_RGB_COLORS)) { rfree(pBuffer); DeleteDC(hScreenDC); return 1; } --- 529,537 ---- // Assume that the hDC is the DC where the bitmap would have been selected // if indeed it has been selected ! if (!GetDIBits(hScreenDC, hBitmap, 0, pBMI->bmiHeader.biHeight, pBits, pBMI, DIB_RGB_COLORS)) { rfree(pBuffer); DeleteDC(hScreenDC); + if (bFlag) DeleteObject(hBitmap); return 1; } *************** *** 487,490 **** --- 541,545 ---- rfree(pBuffer); DeleteDC(hScreenDC); + if (bFlag) DeleteObject(hBitmap); return 3; } *************** *** 496,499 **** --- 551,555 ---- rfree(pBuffer); DeleteDC(hScreenDC); + if (bFlag) DeleteObject(hBitmap); return 3; } *************** *** 504,507 **** --- 560,564 ---- DeleteDC(hScreenDC); + if (bFlag) DeleteObject(hBitmap); return 0; |