-
Is it possible to rotate a text that is being drawn atop of an image? Can't find a method that accepts an angle for rotation. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
image.Mutate(x => x
.SetDrawingTransform(Matrix3x2Extensions.CreateRotationDegrees(45, new PointF(50, 50))) // set a transform to be applied to all drawing operations
.DrawText("foo bar", font, Color.Black, new PointF(50, 50))); // draw the text The one gotcha you might hit is the rotation origin of the matrix thus you will most likely need/want to set the point in the This API can be used to apply full matrix transforms to the items being drawn so can also be used for skewing, translating/offsetting, and scaling and as its a transformation matrix you can do them all at once. or alternatively using image.Mutate(x => x
.DrawText(
new DrawingOptions {
Transform = Matrix3x2Extensions.CreateRotationDegrees(45, new PointF(50, 50))
},
"foo bar",
font,
Color.Black,
new PointF(50, 50))); |
Beta Was this translation helpful? Give feedback.
The one gotcha you might hit is the rotation origin of the matrix thus you will most likely need/want to set the point in the
CreateRotationDegrees(angle, point)
call to the same as the text drawing point to get the result you expect otherwise we will end up rotating around0,0
(top left) and you can end up with text in odd places.This API can be used to apply full matrix transforms to the items being drawn so can also be used…