本帖最后由 xianshuixx 于 2010-08-30 15:58:52 编辑

解决方案 »

  1.   

    你确定你的摄像头采集到的图片是编码为bmp格式的吗?
      

  2.   

    哦,好的。。因为如果我新建一个文档,肯定有一个激活的view,那么,用getactiveframe和getactiveview就一定有结果,而且能够正常显示,所以我认为问题一定出在前面,而不是摄像头的配置方面请看: CWinApp* pWinApp = AfxGetApp();
    POSITION FirstDocTemplatePos = pWinApp->GetFirstDocTemplatePosition();
    CDocTemplate* pNextDocTemplate = pWinApp->GetNextDocTemplate(FirstDocTemplatePos); ActivateFrame(); CDocument* pNewDoc = pNextDocTemplate->CreateNewDocument();
    CCreateContext pContext;
    pContext.m_pNewViewClass = RUNTIME_CLASS(CMyView);
    pContext.m_pCurrentDoc = pNewDoc;
    pContext.m_pNewDocTemplate = pNextDocTemplate;
    pContext.m_pLastView = NULL;
    pContext.m_pCurrentFrame = NULL;// (CFrameWnd *)AfxGetMainWnd();
    CWnd* pView = CreateView(&pContext);
    SetActiveView((CView*) pView);
    CDC *pDC = pView->GetDC(); //得到VIEW的DC
    //同时将原始数据进行上下翻转
    ConvertBayer2Rgb(CAM_m_pImageBuffer,CAM_m_pRawBuffer,CAM_Width,CAM_Height,CAM_ConvertType,CAM_m_pLutR,CAM_m_pLutG,CAM_m_pLutB,true,CAM_Layout); // 摄像头的操作必须
    BYTE *p = NULL, * q = NULL;
    SetStretchBltMode(pDC->GetSafeHdc(),COLORONCOLOR);
    //在视图客户区显示图像
    StretchDIBits(pDC->GetSafeHdc(),
    0,
    0,
    CAM_Width,
    CAM_Height,
    0,
    0,
    CAM_Width,
    CAM_Height,
    CAM_m_pImageBuffer, //图像缓冲区
    CAM_m_pBmpInfo, //BMP图像描述信息
    DIB_RGB_COLORS,
    SRCCOPY
    );

    pView->ReleaseDC(pDC);