+ -
当前位置:首页 → 问答吧 → 图像非整数倍放大缩小问题,,高手指点下,谢谢~!

图像非整数倍放大缩小问题,,高手指点下,谢谢~!

时间:2011-12-19

来源:互联网

void CCywView::Onfd2b() 
{
// TODO: Add your command handler code here
CCywDoc * pDoc = GetDocument();
int i,j,nBmpHeight,nnWidth,nBmpWidth,a,b;
nBmpHeight=pDoc->BmpHeight*2;
nBmpWidth=pDoc->nWidth*2;

BYTE *npImage;
npImage=(BYTE*)malloc(sizeof(BYTE)*(nBmpHeight*nBmpWidth));


if (nBmpWidth%4==0)
{
nnWidth=nBmpWidth;
}
else
{
nnWidth=(nBmpWidth+3)/4*4;
}
for (i = 0; i < nBmpHeight; i++)
for(j = 0; j < nBmpWidth; j++)
{
a=(int)i/2;
b=(int)j/2;
npImage[i*nnWidth+j]=pDoc->pImage[a*pDoc->nWidth+b];
}



fangda dlg;

dlg.pImage=npImage;
dlg.BmpWidth=nBmpWidth;
dlg.BmpHeight=nBmpHeight;
dlg.pBitMapInfo=pDoc->pBitMapInfo;
dlg.BitMapFileHeader=pDoc->BitMapFileHeader;
dlg.ColorUsed=pDoc->ColorUsed;
dlg.BitCount=pDoc->BitCount;
dlg.nWidth=nnWidth;
dlg.DoModal();

free(npImage);

}

作者: ye461166855   发布时间: 2011-12-19

试试opencv的cvResize函数

作者: fengbingchun   发布时间: 2011-12-19

归根结底是坐标变换加上插值的问题,至于代码还是自己多看几遍吧

作者: renshengrumenglibing   发布时间: 2011-12-19