怎样将HBITMAP中的图像旋转180度

解决方案 »

  1.   

    http://community.csdn.net/Expert/topic/5047/5047922.xml?temp=.9740869
      

  2.   

    下面的程序是把窗体画面旋转180度,很容易改成你的
    void CTESTDlg::OnButton1() 
    {
    // TODO: Add your control notification handler code here
    CDC *pDC=GetDC();
    COLORREF cl;
    CRect rect;
    GetClientRect(rect);
    HBITMAP b1;
    HDC hDC;
    hDC=CreateCompatibleDC(pDC->GetSafeHdc());
    b1=CreateCompatibleBitmap(hDC,rect.Width(),rect.Height());
    SelectObject(hDC,b1);
    int i,j;
    for(i=0;i<rect.Width();i++)
    for(j=0;j<rect.Height();j++)
    {
    cl=pDC->GetPixel(i,j);
    SetPixel(hDC,rect.Width()-i,rect.Height()-j,cl);
    }
    BitBlt(pDC->GetSafeHdc(),0,0,rect.Width(),rect.Height(),hDC,0,0,SRCCOPY);
    DeleteObject(b1);
    }
      

  3.   

    pDC->StretchBlt(0,0, width, height, &memDC, width-1, height-1, -width, -height, SRCCOPY);
      

  4.   

    HDC m_hdc;   
    HBITMAP m_hbmp;
    CBitmap m_bitmap;    BITMAPINFO bitmapInfo;    
    m_hdc   =   CreateCompatibleDC(NULL);   
    memcpy(&bitmapInfo,(BITMAPINFO*)src,  sizeof(BITMAPINFO)); 
    m_hbmp   =   CreateDIBSection(m_hdc,   &bitmapInfo,   DIB_RGB_COLORS,(void**)temp,  NULL,   0);   

    if(   m_hbmp   ==   NULL   )     
    return ; m_bitmap.Attach(   m_hbmp   );   
    BITMAP   bmp;   
    m_bitmap.GetBitmap(&bmp);   
    DWORD   dwCount=(DWORD)   bmp.bmWidthBytes   *   bmp.bmHeight;   
        
    if(m_bitmap.SetBitmapBits(dwCount,temp)!=dwCount)   
    {   
    AfxMessageBox("DIB   build   error!");   
    return;   
    }  
    将m_hbmp的图像旋转180度,我是个菜鸟,对图像一敲不通,希望楼上的哥哥帮忙解答一下