socket 中穿过来的图像数据包直接显示出来就是图像,可是小弟要将图像处理一下(放大)对图像怎么操作就不知道了,不知道句柄,有没有解决办法或者相关的书啊

解决方案 »

  1.   

    关于图像显示、放大,看个例子
    void CBmpView::OnDraw(CDC* pDC)
    {
    CAutoStitchDoc* pDoc = GetDocument();
    // TODO: add draw code here
    if (pDC->IsPrinting())
    return;
    CRect rect;
    GetClientRect(&rect);
    if (m_szFilename.IsEmpty()||m_hbmp==NULL)
    {
    // pDC->FillSolidRect(&rect,RGB(255,255,255));
    return;
    }
    CAutoStitchApp* pApp=(CAutoStitchApp*)AfxGetApp();
    m_pDC->FillSolidRect(&rect,pApp->m_backColor); CBitmap* bitmap;
    CDC dc;
    dc.CreateCompatibleDC(pDC);
    // HBITMAP hbmp=(HBITMAP)LoadImage(NULL,m_szFilename,IMAGE_BITMAP,0,0,LR_LOADFROMFILE);
    // if (hbmp==NULL)
    // return;
    bitmap=CBitmap::FromHandle(m_hbmp);
    CBitmap* pOldBmp=dc.SelectObject(bitmap);
    if (!m_bTrackMode)
    {
    m_pDC->BitBlt(m_topLeft.x,m_topLeft.y,m_width,m_height,&dc,0,0,SRCCOPY);
    }
    else
    {
    int width=(int)(m_width*pDoc->m_ratio*m_pGroup->m_xr);
    int height=(int)(m_height*pDoc->m_ratio*m_pGroup->m_yr);
    m_pDC->StretchBlt(m_topLeft.x,m_topLeft.y,width,height,&dc,0,0,m_width,m_height,SRCCOPY);
    }
    dc.SelectObject(pOldBmp);
    pDC->BitBlt(0,0,rect.Width(),rect.Height(),m_pDC,0,0,SRCCOPY);
    // DeleteObject(hbmp);
    }