Graphics g(pDC->GetSafeHdc());
SolidBrush brush(Color(200,88,88,88));
int x = 100, y = 100;
int w = 50, h = 80;
g.FillRectangle(&brush, x, y, w, h); // Original Rectangle
g.TranslateTransform(x+(w/2), y+(h/2), MatrixOrderAppend); // Fix position
g.RotateTransform(45); // Rotate 45 degrees
g.FillRectangle(&brush, x, y, w, h); // Rotated Rectangle
g.ResetTransform();
//或
Graphics g(pDC-> m_hDC);
g.SetSmoothingMode(SmoothingModeAntiAlias);
Matrix matrix(1.0f,0.0f,0.0f,1.0f,0.0f,0.0f);
matrix.RotateAt(90,PointF(wid[0],len[0]),MatrixOrderAppend);
matrix.Translate(-len[0],wid[0]-len[0],MatrixOrderAppend);
g->SetTransform(&matrix);
GDI+ Rotate Rectangle
最新推荐文章于 2022-10-22 16:37:06 发布