GDI+ Rotate Rectangle

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);  


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章