/
//图像处理
void CGeoPhotoProc::ReversePicture(CString strPicName)
{
CImage image;
if(image.Load(strPicName)==E_FAIL)
return ;
//图像每一行的字节数
int nRowBytes = image.GetPitch();
int nWidth = image.GetWidth();
int nHeight = image.GetHeight();
//每个像素所占的字节数
int nClrCount = image.GetBPP() / 8;
LPBYTE p;
//上下对调
for(int index = 0; index < nClrCount; index++)
{
LPBYTE pOrg=p = (LPBYTE)image.GetBits();
pOrg += (nHeight-1)*nRowBytes;
for(int i = 0; i < nHeight/2; i++)
{
for(int j = 0; j < nWidth; j++)
{
BYTE nB=p[j*nClrCount + index];
p[j*nClrCount + index]=pOrg[j*nClrCount + index] ;
pOrg[j*nClrCount + index] = nB;
}
//如果nRowBytes>0 则从开始到结尾
//如果nRowBytes<0, 则从结尾到开始
p += nRowBytes;
pOrg-=nRowBytes;
}
}
image.Save(strPicName);
}
//左右对调
void CGeoPhotoProc::SymmetryPicture(CString strPicName)
{
CImage image;
if(image.Load(strPicName)==E_FAIL)
return ;
//图像每一行的字节数
int nRowBytes = image.GetPitch();
int nWidth = image.GetWidth();
int nHeight = image.GetHeight();
//每个像素所占的字节数
int nClrCount = image.GetBPP() / 8;
LPBYTE p;
//左右对调
for(int index = 0; index < nClrCount; index++)
{
p = (LPBYTE)image.GetBits();
for(int i = 0; i < nHeight; i++)
{
for(int j = 0; j < nWidth/2; j++)
{
BYTE nB=p[(nWidth-1-j)*nClrCount + index];
p[(nWidth-1-j)*nClrCount + index]=p[j*nClrCount + index] ;
p[j*nClrCount + index] = nB;
}
//如果nRowBytes>0 则从开始到结尾
//如果nRowBytes<0, 则从结尾到开始
p += nRowBytes;
}
}
image.Save(strPicName);
}