// 将原图像的信息拷贝至新图像
LPBITMAPINFOHEADER m_lpBMIH_new;
int nSize = bmfh.bfOffBits - sizeof(BITMAPFILEHEADER);
m_lpBMIH_new = (LPBITMAPINFOHEADER) new char[nSize];
memcpy(m_lpBMIH_new, m_lpBMIH, nSize);
// 对目标图像的高、宽、像素区大小等信息进行修改
m_lpBMIH_new->biHeight = m_RB.y - m_LU.y + 1;
m_lpBMIH_new->biWidth = m_RB.x - m_LU.x + 1;
m_lpBMIH_new->biSizeImage = n_DesRowByte * m_lpBMIH_new->biHeight;
// (3)对像素区进行逐行拷贝,并对每行拷贝结果进行偏移
LPBYTE m_lpImage_new, m_lpSrc_Start, m_lpDes_Start;
m_lpImage_new = (LPBYTE) new char[m_lpBMIH_new->biSizeImage];
int i;
for(i = m_RB.y; i >= m_LU.y; i--){
m_lpSrc_Start = m_lpImage + (n_Height-1-i) * n_OriRowByte + n_StartByte;
m_lpDes_Start = m_lpImage_new + (m_RB.y-i) * n_DesRowByte;
CopyRow(m_lpSrc_Start, m_lpDes_Start, n_CopyByte, n_StartBit, n_EndBit, n_DesRowByte);
}
|