图像镜像(二)

2014-11-24 11:16:15 · 作者: · 浏览: 1
需要注意,pit和pit2的值并不一样,所以如果使用一个值,会导致不同的结果出现
//CString str;
//str.Format(TEXT("%d"),pit2);
//MessageBox(str);
//str.Format(TEXT("%d"),pit2);
//MessageBox(str);
int bitCount=myImage1.GetBPP()/8;
int bitCount2=myImage2.GetBPP()/8;
//CString str;
//str.Format(TEXT("%d"),bitCount);
//MessageBox(str);
//str.Format(TEXT("%d"),bitCount2);
//MessageBox(str);
int newValue;
int tempR,tempG,tempB;
int key1,key2; //用来控制方向
//srand((unsigned)time(NULL));
//key1=rand()%100;
//key2=rand()%100;
//if(key1>50)
// key1=-1;
//else
// key1=1;
//if(key2<50)
// key2=1;
//else
// key2=-1;
//int xTrans=key1*rand()%(int)(maxX/1.5)+1;
//int yTrans=key2*rand()%(int)(maxY/1.5)+1;
//说明:将生产的图像作为24位图处理。
for (int y=0; y for (int x=0; x if((maxX-1-x>=0)&&(maxX-1-x<=maxX))
{ tempR=(int)(int)(*(pRealData+pit*y+(maxX-1-x)*bitCount));
if(bitCount==1)
{tempG=tempR;
tempB=tempR;}
else
{

tempG=(int)(int)(*(pRealData+pit*y+(maxX-1-x)*bitCount+1));
tempB=(int)(int)(*(pRealData+pit*y+(maxX-1-x)*bitCount+2));
}
}
else
{
tempR=255;
tempG=0;
tempB=0;
}

*(pRealData2+pit2*y+x*bitCount2)=tempR;
*(pRealData2+pit2*y+x*bitCount2+1)=tempG;
*(pRealData2+pit2*y+x*bitCount2+2)=tempB;
}

}
Invalidate();
}


void CDIGTLSView::OnMirrorCustome() //自定义水平、垂直镜像
{
if(myImage1.IsNull())
OnOpenResourceFile();
CMyMirror myDlg;
int myAngle;
if(myDlg.DoModal () == IDOK)
{ www.2cto.com
myAngle=myDlg.myMirror;
// CString str;
//str.Format(TEXT("%d"),myAngle);
//MessageBox(str);
if(myAngle==0)
OnMirrorHorizental();
else

OnMirrorVertical();
}
else
{
myImage2.Destroy();
Invalidate();
}
}
作者:superdont