如何水平翻转贴图?
如何水平翻转贴图?
[最优解释]
//上下翻转
BOOL UpDownReverse(LPBYTE lpDIBits, long lWidth, long lHeight,long bitcount)
{
long i,j,k,l,temp;
unsigned char *lpBits1,*lpBits2;
k=lHeight/2;//将位图分成上下两个部分,然后上下对应的扫描行象素交换
l=((lWidth*bitcount+31)> > 5) < <2;//四字节对齐
for(j=0;j <k;j++)
for(i=0;i <l;i++)
{ //指向位图上半部分的一行扫描行的象素
lpBits1=lpDIBits+(lHeight-1-j)*l+i;
//指向位图下半部分的一行扫描行的象素
lpBits2=lpDIBits+j*l+i;
//交换两部分象素
temp=*lpBits1;
*lpBits1=*lpBits2;
*lpBits2=(unsigned char)temp;
}
return TRUE;
}
myGraphics.RotateTransform(angle,MatrixOrderAppend);
myGraphics.TranslateTransform(pnt.x,pnt.y,MatrixOrderAppend);
//将图片画在pnt处,图片的中心点在rect1矩形的中心,DrawImage时坐标为图片在原坐标系的坐标减去坐标系的偏移
myGraphics.DrawImage(pImg,- rect1.Width(),- rect1.Height()/2,rect1.Width(), rect1.Height());
myGraphics.ResetTransform(); //将坐标系复位
Graphics* g;
GraphicsPath myGraphicsPath(FillModeAlternate);
int offsetrx=m_EllipseData.point1.x -origin.X;
int offsetry=m_EllipseData.point1 .y -origin.Y;
RectF myRectangle(offsetrx,offsetry ,m_EllipseData.point2.x-m_EllipseData.point1.x,m_EllipseData.point2.y-m_EllipseData.point1 .y );
myGraphicsPath.AddEllipse (myRectangle);
Matrix* myPathMatrix=new Matrix();
myPathMatrix->Rotate(nRotateAngle, MatrixOrderAppend);
myPathMatrix->Translate(origin.X,origin.Y,MatrixOrderAppend );
myGraphicsPath.Transform(myPathMatrix);
g->FillPath(&myBrush, &myGraphicsPath);