/*********************************************** * 工作室 : 天光工作室 * 作者 : 张东斌 * 用途 : *************************************************/ #include "StdAfx.h" #include "..\include\mendc.h" void WINAPI AlphaBlend( HDC hdcResult, int nX, int nY, int nWidth, int nHeight, HDC hdcDest, int nXDest, int nYDest, HDC hdcSrc, int nXSrc, int nYSrc, BYTE bAlpha ) { BITMAPINFOHEADER bih; bih.biSize = sizeof( BITMAPINFOHEADER ); bih.biWidth = nWidth; bih.biHeight = nHeight; bih.biPlanes = 1; bih.biBitCount = 32; bih.biCompression = BI_RGB; bih.biSizeImage = 0; bih.biXPelsPerMeter = 0; bih.biYPelsPerMeter = 0; bih.biClrUsed = 0; bih.biClrImportant = 0; DWORD *pdwSrc, *pdwDest; HBITMAP hbmpSrc, hbmpDest; hbmpSrc = ::CreateDIBSection( hdcSrc, (BITMAPINFO*)&bih, DIB_RGB_COLORS, (void**)&pdwSrc, 0, (DWORD)0 ); hbmpDest = ::CreateDIBSection( hdcDest,(BITMAPINFO*)&bih, DIB_RGB_COLORS, (void**)&pdwDest,0, (DWORD)0 ); HDC hdcMem = ::CreateCompatibleDC( NULL ); HGDIOBJ hobjOld = ::SelectObject( hdcMem, hbmpDest ); ::BitBlt( hdcMem, 0, 0, nWidth, nHeight, hdcDest, nXDest, nYDest, SRCCOPY ); ::SelectObject( hdcMem, hbmpSrc ); ::BitBlt( hdcMem, 0, 0, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, SRCCOPY ); for( int i=0; i>8); pbRGBSrc[1] = (BYTE)(( pbRGBDest[1]*(255-bAlpha)+pbRGBSrc[1]*bAlpha )>>8); pbRGBSrc[2] = (BYTE)(( pbRGBDest[2]*(255-bAlpha)+pbRGBSrc[2]*bAlpha )>>8); pbRGBSrc += 4; pbRGBDest += 4; } } ::BitBlt( hdcResult, nX, nY, nWidth, nHeight, hdcMem, 0, 0, SRCCOPY ); ::SelectObject( hdcMem, hobjOld ); ::DeleteDC( hdcMem ); ::DeleteObject( hbmpSrc ); ::DeleteObject( hbmpDest ); } void WINAPI DrawAnimation( RECT *prect, HDC hDCDest, HDC hDCSrc, int nType, int nStep, int nTimeDelay ) { ASSERT( nStep >= 0 ); ASSERT( nTimeDelay >= 0 ); const int nLeft = prect->left; const int nTop = prect->top; const int nRight = prect->right; const int nBottom = prect->bottom; const int nWidth = nRight - nLeft; const int nHeight = nBottom - nTop; if ( nStep )//&& nWidth>1 && nHeight>1 ) switch ( nType) { case ANIMATE_NONE: break; case ANIMATE_SLIDE_TTB: { while( nHeight/nStep == 0 ) --nStep; int nStepHeight = nHeight / nStep; for ( int ntmpHeight=nStepHeight; ntmpHeightGetSafeHdc(), this->GetSafeHdc(), nType, nStep, nTimeDelay ); }