/*********************************************************************** * Initializes the cards.dll library. Loads the card bitmaps from the * resources, and initializes the card size variables. */ BOOL WINAPI cdtInit(int *width, int *height) { BITMAP bm; int i; TRACE("(%p, %p)\n", width, height); for(i = 0; i <= CARD_MAX; i++) cardBitmaps[i] = 0; for(i = 0; i <= CARD_MAX; i++) { cardBitmaps[i] = LoadBitmapA(hInst, MAKEINTRESOURCEA(i)); if(cardBitmaps[i] == 0) { cdtTerm(); return FALSE; } } GetObjectA(cardBitmaps[0], sizeof(BITMAP), &bm); *width = cardWidth = bm.bmWidth; *height = cardHeight = bm.bmHeight; return TRUE; }
CardLib::~CardLib() { if ( hCardDll ) { cdtTerm(); FreeLibrary(hCardDll); hCardDll = NULL; } }
BOOL APIENTRY cdtInit(INT FAR *pdxCard, INT FAR *pdyCard) /* * Parameters: * pdxCard, pdyCard * Far pointers to ints where card size will be placed * * Returns: * True when successful, False when it can't find one of the standard * bitmaps. */ { BITMAP bmCard; HDC hdc = NULL; HBITMAP hbmDstBitmap; HANDLE hDstOld; HANDLE hSrcOld; HDC hdcDstMemory; HDC hdcSrcMemory; #ifdef DLL if (cInits++ != 0) { *pdxCard = dxCard; *pdyCard = dyCard; return fTrue; } #endif hbmGhost = LoadBitmap( hinstApp, MAKEINTRESOURCE(IDGHOST)); hbmDeckX = LoadBitmap( hinstApp, MAKEINTRESOURCE(IDX)); hbmDeckO = LoadBitmap( hinstApp, MAKEINTRESOURCE(IDO)); if(hbmGhost == NULL || hbmDeckX == NULL || hbmDeckO == NULL) { goto Fail; } GetObject( hbmGhost, sizeof( BITMAP), (LPSTR)&bmCard); dxCard = *pdxCard = bmCard.bmWidth; dyCard = *pdyCard = bmCard.bmHeight; // // Create two compatible memory DCs for bitmap conversion. // hdc = GetDC(NULL); hdcSrcMemory = CreateCompatibleDC(hdc); hdcDstMemory = CreateCompatibleDC(hdc); if ((hdcSrcMemory == NULL) || (hdcDstMemory == NULL)) { goto Fail; } // // Create a compatible bitmap for the conversion of the Ghost // bitmap, blt the loaded bitmap to the compatible bitmap, and // delete the original bitmap. // hbmDstBitmap = CreateCompatibleBitmap(hdc, dxCard, dyCard); if (hbmDstBitmap == NULL) { goto Fail; } hSrcOld = SelectObject(hdcSrcMemory, hbmGhost); hDstOld = SelectObject(hdcDstMemory, hbmDstBitmap); BitBlt(hdcDstMemory, 0, 0, dxCard, dyCard, hdcSrcMemory, 0, 0, SRCCOPY); SelectObject(hdcSrcMemory, hSrcOld); SelectObject(hdcDstMemory, hDstOld); DeleteObject(hbmGhost); hbmGhost = hbmDstBitmap; // // Create a compatible bitmap for the conversion of the DeckX // bitmap, blt the loaded bitmap to the compatible bitmap, and // delete the original bitmap. // hbmDstBitmap = CreateCompatibleBitmap(hdc, dxCard, dyCard); if (hbmDstBitmap == NULL) { goto Fail; } hSrcOld = SelectObject(hdcSrcMemory, hbmDeckX); hDstOld = SelectObject(hdcDstMemory, hbmDstBitmap); BitBlt(hdcDstMemory, 0, 0, dxCard, dyCard, hdcSrcMemory, 0, 0, SRCCOPY); SelectObject(hdcSrcMemory, hSrcOld); SelectObject(hdcDstMemory, hDstOld); DeleteObject(hbmDeckX); hbmDeckX = hbmDstBitmap; // // Create a compatible bitmap for the conversion of the DeckO // bitmap, blt the loaded bitmap to the compatible bitmap, and // delete the original bitmap. // hbmDstBitmap = CreateCompatibleBitmap(hdc, dxCard, dyCard); if (hbmDstBitmap == NULL) { } hSrcOld = SelectObject(hdcSrcMemory, hbmDeckO); hDstOld = SelectObject(hdcDstMemory, hbmDstBitmap); BitBlt(hdcDstMemory, 0, 0, dxCard, dyCard, hdcSrcMemory, 0, 0, SRCCOPY); SelectObject(hdcSrcMemory, hSrcOld); SelectObject(hdcDstMemory, hDstOld); DeleteObject(hbmDeckO); hbmDeckO = hbmDstBitmap; // // Delete the compatible DCs. // DeleteDC(hdcDstMemory); DeleteDC(hdcSrcMemory); ReleaseDC(NULL, hdc); return fTrue; Fail: if (hdc != NULL) { ReleaseDC(NULL, hdc); } cdtTerm(); return fFalse; }