Si vous voulez une méthode pour dessiner une chaîne mis en rotation à la position centrale de cordes, essayez la méthode suivante:
public void drawRotatedText(Bitmap bmp, int x, int y, float angle, string text, Font font, Brush brush)
{
Graphics g = Graphics.FromImage(bmp);
g.TranslateTransform(x, y); // Set rotation point
g.RotateTransform(angle); // Rotate text
g.TranslateTransform(-x, -y); // Reset translate transform
SizeF size = g.MeasureString(text, font); // Get size of rotated text (bounding box)
g.DrawString(text, font, brush, new PointF(x - size.Width/2.0f, y - size.Height/2.0f)); // Draw string centered in x, y
g.ResetTransform(); // Only needed if you reuse the Graphics object for multiple calls to DrawString
g.Dispose();
}
Meilleures salutations Hans Milling ...
Je l'ai déjà essayé, mais alors tous mes graphiques dessinés sont tournés. Ce n'est pas très utile. – eagle999
@ eagle999 utilisez ResetTransform() une fois que vous avez terminé de dessiner le texte pivoté –