本帖最后由 cg_qiujie 于 2011-04-08 09:33:34 编辑

解决方案 »

  1.   

    关键就是取得像素。可以用OpenCV等来出来 
      

  2.   

    你可以用CXimage直接转换成bmp格式再处理,或者用其他的工具转成bmp的
      

  3.   

    VS2005 以上用自带的 CImage类就可以了
      

  4.   

    建议用 CXimage ,很不错的,http://www.codeproject.com/KB/graphics/cximage.aspx
      

  5.   

    vc6 请使用IPicture接口,这个是标准,vc6以上请使用gdi+
      

  6.   

    http://www.vckbase.com/document/viewdoc/?id=446
      

  7.   

    上源码吧
    BOOL DrawRect(CWnd *pWnd, LPCTSTR strPath,  CRect &Rect, int nMode )
    {
    ASSERT(IsWindow(pWnd->GetSafeHwnd()));
    IStream   *pStm;       
    CFileStatus   fstatus;       
    CFile   file;       
    LONG   cb;     
    HGLOBAL   hGlobal ;
    CDC   *pDC=pWnd->GetDC();   
    if   (file.Open(strPath,CFile::modeRead)&&   
    file.GetStatus(strPath,fstatus)&&     
    ((cb   =   fstatus.m_size)   !=   -1))       
    {       
    hGlobal=   GlobalAlloc(GMEM_MOVEABLE,   cb);       
    LPVOID   pvData   =   NULL;       
    if   (hGlobal   !=   NULL)       
    {       
    pvData   =   GlobalLock(hGlobal);   
    if   (pvData   !=   NULL)       
    {       
    file.ReadHuge(pvData,   cb);       
    GlobalUnlock(hGlobal);       
    CreateStreamOnHGlobal(hGlobal,   TRUE,   &pStm);    
    }     
    }     
    }   
    else   
    {   
    return   FALSE;   
    }   //打开文件结束   

    try{
    IPicture   *pPic;     
    if(SUCCEEDED(OleLoadPicture(pStm,fstatus.m_size,TRUE,IID_IPicture,(LPVOID*)&pPic)))     

    {     

    OLE_XSIZE_HIMETRIC   hmWidth;       
    OLE_YSIZE_HIMETRIC   hmHeight;       
    pPic->get_Width(&hmWidth);       
    pPic->get_Height(&hmHeight); 
    DWORD width, height;
    CSize sz(hmWidth,hmHeight);
    pDC->HIMETRICtoDP(&sz); 
    switch(nMode)
    {
    case BITBLT:
    width = Rect.Width();
    height = Rect.Height();
    break;
    case STRETCH:
    {

    width = sz.cx;
    height = sz.cy;
    Rect.right = width + Rect.left;
    Rect.bottom = height + Rect.top;
    }
    break;
    case AUTO:
    {
    width = Rect.Width();
    height = sz.cy * width / sz.cx ;

    Rect.right = width + Rect.left;
    Rect.bottom = height + Rect.top;
    }
    }


    //先将图片画到内存DC中

    CDC MemDC;
    MemDC.CreateCompatibleDC(NULL); 
    CBitmap hbitmap;
    hbitmap.CreateCompatibleBitmap(pDC, sz.cx, sz.cy);   
    CBitmap   *pOldBit = MemDC.SelectObject(&hbitmap);


    if(FAILED(pPic->Render(MemDC, 0, 0, sz.cx, sz.cy, 0,   
    hmHeight,hmWidth, -hmHeight,NULL)))       
    {   
    pPic->Release();
    hbitmap.DeleteObject();
    throw(-1);

    }   
    else
    {
    pDC->SetBkMode(TRANSPARENT);
    pDC->SetStretchBltMode(HALFTONE);
    pDC->StretchBlt(Rect.left, Rect.top, width,height,&MemDC,0,0,sz.cx,sz.cy,SRCCOPY  );  
    }
    hbitmap.DeleteObject();
    pPic->Release();       
    }       
    else       
    {   
    throw(0);     
    }   
    }
    catch(int nErrorCode)
    {
    switch(nErrorCode)
    {
    case -1:
    TRACE("Failed to Render!");
    break;
    case 0:
    TRACE("Failed to LoadPicture!");
    break;

    } GlobalFree(hGlobal);
    return false;
    }
    GlobalFree(hGlobal);
    return   true;   

    }
      

  8.   

    我使用ms提供的gdi+ 来打开jpg 缩放,以及修改质量. 保存为bmp,jpg,png
      

  9.   

    用opencv吧,很容易实现,而且有现成的函数可调用,
    用CxImage也不错,而且它有个demo,你可以看看