void Sprite::SetImage( const CImage* pImage ) { Gdiplus::Bitmap* image = new Gdiplus::Bitmap( pImage->GetWidth(), pImage->GetHeight() ); Gdiplus::Rect bound( 0, 0, pImage->GetWidth(), pImage->GetHeight() ); Gdiplus::BitmapData lockedBitmapData; int bpp = pImage->GetBPP(); int imageRowSize = pImage->GetWidth() * (bpp/8); if ( bpp == 24 ) { image->LockBits( &bound, Gdiplus::ImageLockModeWrite, PixelFormat24bppRGB, &lockedBitmapData ); } else if ( bpp == 32 ) { image->LockBits( &bound, Gdiplus::ImageLockModeWrite, PixelFormat32bppARGB, &lockedBitmapData ); } else { // we shouldn't be getting here AfxDebugBreak(); return; } BYTE* pSrcPointer = (BYTE*)pImage->GetBits(); BYTE* pDstPointer = (BYTE*)lockedBitmapData.Scan0; for ( int i=0; i<pImage->GetHeight(); i++ ) { memcpy( pDstPointer, pSrcPointer, imageRowSize ); pSrcPointer += pImage->GetPitch(); pDstPointer += lockedBitmapData.Stride; } image->UnlockBits( &lockedBitmapData ); SetImage( image, true ); }
출처:http://forums.devshed.com/c-programming-42/converting-cimage-to-gdiplus-image-351742.html
'MFC' 카테고리의 다른 글
레지스트리 관련 api함수들 (0) | 2011.08.26 |
---|---|
레지스트리값을 이용하여 시리얼포트 스캔하기 (0) | 2011.08.26 |
릴리즈 모드로 디버깅 하기 (0) | 2011.08.26 |
더블 버퍼링 (0) | 2011.08.26 |
다이얼로그 전체화면 만들기 (0) | 2011.08.26 |