The DrawText
method is used to render text onto a bitmap within a specified rectangular area. This method allows for customization of text rendering through the use of flags and a defined scope.
The DrawText
method is used to render text onto a bitmap within a specified rectangular area. This method allows for customization of text rendering through the use of flags and a defined scope.
To use the DrawText
method, you need to provide a Scope
object that defines the text to be rendered, a Rect
object that specifies the area on the bitmap where the text should be drawn, and a TextFlag
enumeration that determines the rendering options.
Ensure that the bitmap is properly initialized and that the Scope
contains valid text data. The Rect
should be within the bounds of the bitmap to avoid rendering issues.
// Example of using DrawText method var bitmap = new Bitmap(); var textScope = new TextRendering.Scope("Hello, World!"); var drawArea = new Rect(10, 10, 200, 50); var textFlags = TextFlag.Center | TextFlag.Bold; bitmap.DrawText(textScope, drawArea, textFlags);