3>(x1>x2?x1:x2)?x3:(x1>x2?x1:x2);
maxWidth = maxWidth>0?maxWidth:0;
maxHeight = y3>(y1>y2?y1:y2)?y3:(y1>y2?y1:y2);
maxHeight = maxHeight>0?maxHeight:0;
DstWidth = maxWidth - minWidth;
DstHeight = maxHeight - minHeight;
dcDst = CreateCompatibleDC(dcSrc);
newBitmap = CreateCompatibleBitmap(dcSrc,(int)DstWidth,(int)DstHeight);
SelectObject(dcDst,newBitmap);
for( int I = 0 ;I<DstHeight;I++)
{
for(int J = 0 ;J< DstWidth;J++)
{
srcX = (J + minWidth) * cosA + (I + minHeight) * sinA;
srcY = (I + minHeight) * cosA - (J + minWidth) * sinA;
if( (srcX >= 0) && (srcX <= SrcWidth) &&(srcY >= 0) && (srcY <= SrcHeight))
{
BitBlt(dcDst, J, I, 1, 1, dcSrc,(int)srcX, (int)srcY, SRCCOPY);
}
}
}
//显示旋转后的位图
BitBlt(hDC,200,200,(int)DstWidth,(int)DstHeight,dcDst,0,0,SRCCOPY);
DeleteObject(newBitmap);
DeleteDC(dcDst);
}
最后我们调用就可以了:
double angle = (45/180.0)*3.14159;//旋转45Degree,可为任意角度
RotateAnyAngle(dcSrc,bmpWidth,bmpHeight,angle,);
到这里就大功告成了.