返回信息流附件(871.9KB) 777777.bmp
附件(873.6KB) 3212.bmp
大家看图片,有3个问题,只有部分移动?移动部分颜色出现问题?我只下移,但是图像不对?
代码如下:(平移部分,应该没错,会不会是指针呢,但是我调试了很久,指针应该没问题...)
BOOL CDib::Draw_pingyi(CDC *pDC, int x_move,int y_move,int nX, int nY, int nWidth, int nHeight, int mode)
{
LPBYTE lpsrc;
LPBYTE lpdst;
LPBYTE temp;
LONG i,llinebytes;
int i0=0,j0=0;
if (m_pDib == NULL)
return (FALSE);
// 获取位图宽度和高度赋值
if (nWidth == - 1)
nWidth = m_pBIH->biWidth;
if (nHeight == - 1)
nHeight = m_pBIH->biHeight;
llinebytes=(((nWidth*8)+31)/32*4);/////计算图像每行的字节数
temp=new BYTE[llinebytes*nHeight];
lpdst=(LPBYTE)temp;
memset(lpdst,(BYTE)255,llinebytes*nHeight);
for(i=0;i<nWidth;i++)
{ for(int j=0;j<nHeight;j++)
{
lpsrc=(LPBYTE)m_pDibBits+llinebytes*(nHeight-1-j)+i;
i0=i+x_move;
j0=j+y_move;
if((i0>=0)&&(i0<nWidth)&&(j0>=0)&&(j0<nHeight))
{
lpdst=(LPBYTE)temp+llinebytes*(nHeight-1-j0)+i0;
*lpdst=*lpsrc;
}
else
{ *((unsigned char *)lpdst)=255;
}
}
}
memcpy(m_pDibBits,temp,llinebytes*nHeight);
// 绘制位图
StretchDIBits(pDC->m_hDC, nX, nY, nWidth, nHeight, 0, 0, m_pBIH->biWidth, m_pBIH->biHeight, m_pDibBits, (BITMAPINFO*)m_pBIH, BI_RGB, mode);
delete temp;
return (TRUE);
}
这是一条镜像帖。来源:北邮人论坛 / cpp / #19171同步于 2009/2/11
该镜像源已超过 30 天没有更新,可能在源站已被删除。
CPP机器人发帖
vc图像处理平移问题
qzp
2009/2/11镜像同步1 回复
订阅后,新回复会通过你的通知中心匿名送达。
1 条回复