首先说下问题情况,GetBitmapBits获取DDB的图素位; GetDIBits获取DIB的图素位; DDB只支持左上到右下; DIB除了BIEMAPCOREHEADER类型外的非压缩位图, 都支持左上到右下和左下到右上的次序; DDB图素位每行2字节对齐; DIB图素位每行4字节对齐; 如果你发现图像跌倒了,最简单的方法是把, lpBitmap->bmiHeader.biHeight=nHeight;改成负的: lpBitmap->bmiHeader.biHeight=-nHeight;
推荐以上方法,当然还可以自己写个算法,把图像的数据顺序首尾交换下。
byte* temp = new byte[width*4];
for (int row=height>>1;row>=0;row--)
{
//首尾交换
memcpy(temp,m_pData+width*4*row,width*4);
memcpy(m_pData+width*4*row,m_pData+width*4*(height-row-1),width*4);
memcpy(m_pData+width*4*(height-row-1),temp,width*4);
}
if(temp)delete temp;
本文链接:https://it72.com/11200.htm