在内存设备描述表里放了一副24位位图,并在上面作旋转作图
用BitBlt把位图显示到view里,但是为什么BitBlt会失败呢?
我看过了,位图的初始化,旋转作图都是没有问题的,就是BitBlt不到view里
那位给看看出了什么问题。谢啦!!!
但是当for循环只执行一次的时候,是可以看见输出的,就是多次循环时就不行,不知道为什么?CRect rect ;
BITMAPINFOHEADER bmih ;
HBITMAP          hBitmap ;
CDC              dcMemery ;
int              i , j ;
int              len ;
DWORD            dwSize ;GetClientRect(&rect) ;
pBits = pBitTemp = NULL ;bmih.biBitCount      = 24 ;
bmih.biClrImportant  = 0 ;
bmih.biClrUsed       = 0 ;
bmih.biCompression   = BI_RGB ;
bmih.biHeight        = 600 ;
bmih.biPlanes        = 1 ;
bmih.biSize          = sizeof(BITMAPINFOHEADER) ;
bmih.biSizeImage     = 0 ;
bmih.biWidth         = 800 ;
bmih.biXPelsPerMeter = 0 ;
bmih.biYPelsPerMeter = 0 ;dwSize = (bmih.biWidth * 3 + bmih.biWidth%4)*bmih.biHeight ;//创建位图
hBitmap = ::CreateDIBSection(NULL , (BITMAPINFO*)&bmih ,
DIB_RGB_COLORS , (void**)&pBits , NULL , 0) ;for(i=0 ; i < dwSize-3 ; i += 3)
{//初始化位图
pBits[i]   = 255 ;
pBits[i+1] = 255 ;
pBits[i+2] = 255 ;
}dcMemery.CreateCompatibleDC(pDC) ;
dcMemery.SelectObject(hBitmap) ;XFORM xForm;//设置映射模式
SetGraphicsMode(dcMemery.GetSafeHdc(), GM_ADVANCED);
SetMapMode(dcMemery.GetSafeHdc(), MM_LOENGLISH);GetClientRect(&rect);
DPtoLP(dcMemery.GetSafeHdc(), (LPPOINT) &rect, 2);for(float f=0 ; f < 3.14 ; f += 0.1)
{//旋转
xForm.eM11 = (FLOAT) cos(f);
xForm.eM12 = (FLOAT) sin(f);
xForm.eM21 = (FLOAT) -sin(f);
xForm.eM22 = (FLOAT) cos(f);
xForm.eDx  = (FLOAT) 0.0;
xForm.eDy  = (FLOAT) 0.0;
SetWorldTransform(dcMemery.GetSafeHdc(), &xForm);Ellipse(dcMemery.GetSafeHdc(), (rect.right / 2 - 100), (rect.bottom /
2 + 100),
        (rect.right / 2 + 100), (rect.bottom / 2 - 100));// Draw the interior circle.Ellipse(dcMemery.GetSafeHdc(), (rect.right / 2 -94), (rect.bottom / 2
+ 94),
        (rect.right / 2 + 94), (rect.bottom / 2 - 94));// Draw the key.Rectangle(dcMemery.GetSafeHdc(), (rect.right / 2 - 13), (rect.bottom / 2
 + 113),
        (rect.right / 2 + 13), (rect.bottom / 2 + 50));
Rectangle(dcMemery.GetSafeHdc(), (rect.right / 2 - 13), (rect.bottom / 2
 + 96),
        (rect.right / 2 + 13), (rect.bottom / 2 + 50));Rectangle(dcMemery.GetSafeHdc(), (rect.right / 2 - 13), (rect.bottom / 2
 + 113),
        (rect.right / 2 + 13), (rect.bottom / 2 + 50));
Rectangle(dcMemery.GetSafeHdc(), (rect.right / 2 - 13), (rect.bottom / 2
 + 96),
        (rect.right / 2 + 13), (rect.bottom / 2 + 50));}SetGraphicsMode(pDC->GetSafeHdc(), GM_ADVANCED);
SetMapMode(pDC->GetSafeHdc(), MM_LOENGLISH);pDC->BitBlt(0 , rect.bottom , bmih.biWidth , bmih.biHeight , &dcMemery ,
 0 , rect.bottom , SRCCOPY) ;::DeleteObject(hBitmap) ;
dcMemery.DeleteDC() ;

解决方案 »

  1.   

    用BOOL PlgBlt( POINT lpPoint, CDC* pSrcDC, int xSrc, int ySrc, int nWidth, int nHeight, CBitmap& maskBitmap, int xMask, int yMask );旋转试试。再就是用cdc类中的画rectangle和ellipse函数。
      

  2.   

    看看GetSafeHdc()是不是返回NULL.
      

  3.   

    GetSafeHdc()没有返回NULL
    我是想在内存设备表的位图里对图形做旋转,在显示到view里,而不是直接对位图做旋转,所以用PlgBlt不行的。
      

  4.   

    UP.
    SetWorldTransform(dcMemery.GetSafeHdc(), &xForm);是啥用处阿
    你每次循环都用new xForm看看?第一次把f设成3.13能显示?