打开2560*1920的条纹图象,程序是用VC6.0 MFC写的
通过下面的函数显示(显然是缩小显示),但是发现有较大的失真
BOOL CDib::Display(CDC * pDC, int xDest, int yDest, int nWidthDest, int nHeightDest, 
   int xSrc, int ySrc, int nWidthSrc, int nHeightSrc, DWORD dwRop)
{
CDC MemDC;
MemDC.CreateCompatibleDC(pDC);
CBitmap* pOldBmp = MemDC.SelectObject(m_pBitmap);
CPalette* pOldPal = pDC->SelectPalette(m_pPalette, TRUE);
    pDC->RealizePalette();BOOL bSuccess = pDC->StretchBlt( xDest, yDest, nWidthDest, nHeightDest,&MemDC,
xSrc, ySrc,nWidthSrc, nHeightSrc,dwRop);MemDC.SelectObject(pOldBmp);
pDC->SelectPalette(pOldPal, TRUE);
return bSuccess;
}问了一下才知道好像StretchBlt缩放采用线性插值的算法,所以效果不好我想改用双线性插值或者三次卷积的插值的方法缩放显示,仅仅是用于显示,原图是不希望改变的但是好像显示图象用的都是StretchBlt或者BitBlt,我想问的是能不能自己写个类似StretchBlt的函数,用自己的算法显示,
大概该怎么写的?应为StretchBlt代码我不知道否则的化,难道真的让我先先将图像通过取数据块计算,然后插值缩放,在用这块内存显示
这不是很浪费空间吗!?!
不知道各位是如何做的?

解决方案 »

  1.   

    http://www.codeguru.com/cpp/g-m/bitmap/specialeffects/article.php/c1779/
      

  2.   

    还有这个
    http://www.codeguru.com/cpp/g-m/bitmap/imagemanipulation/article.php/c4881/
      

  3.   

    用这个吧OleLoadPicture(
      IStream * pStream,
                   //Pointer to the stream that contains picture's data
      LONG lSize,  //Number of bytes read from the stream
      BOOL fRunmode,
                   //The opposite of the initial value of the picture's 
                   // property
      REFIID riid, //Reference to the identifier of the interface 
                   // describing the type of interface pointer to return
      VOID ppvObj  //Address of output variable that receives interface 
                   // pointer requested in riid
    );VOID ppvObj是一个IPicture类型得指针.然后在你每次绘制的时候调用Render就可以了,缩放后不会破坏原图.
      

  4.   

    请问 我是处理 内存中的DDB 或 DIB 就是bmp了内存中的,怎么与你这个函数关联使用呢因为这个IStream * pStream,
                   //Pointer to the stream that contains picture's data不明白,您有例子吗?