Class DrawingContext
- Namespace
- nanoFramework.Presentation.Media
- Assembly
- nanoFramework.Graphics.dll
Drawing Context.
public class DrawingContext : DispatcherObject, IDisposable
- Inheritance
-
DrawingContext
- Implements
- Inherited Members
- Extension Methods
Constructors
DrawingContext(int, int)
Creates a drawing context for an empty bitmap of a specific width and height.
public DrawingContext(int width, int height)
Parameters
DrawingContext(Bitmap)
Creates a drawing context for the specified bitmap.
public DrawingContext(Bitmap bmp)
Parameters
bmpBitmapThe bitmap.
Properties
Bitmap
Gets the bitmap associated with this drawing context.
public Bitmap Bitmap { get; }
Property Value
Height
Gets the height of the bitmap.
public int Height { get; }
Property Value
Width
Gets the width of the bitmap.
public int Width { get; }
Property Value
Methods
BlendImage(Bitmap, int, int, int, int, int, int, ushort)
Blends the specified source image onto the current bitmap at the specified location.
public void BlendImage(Bitmap source, int destinationX, int destinationY, int sourceX, int sourceY, int sourceWidth, int sourceHeight, ushort opacity)
Parameters
sourceBitmapThe source image to blend onto the current bitmap.
destinationXintThe x-coordinate of the upper-left corner of the destination rectangle.
destinationYintThe y-coordinate of the upper-left corner of the destination rectangle.
sourceXintThe x-coordinate of the upper-left corner of the source rectangle.
sourceYintThe y-coordinate of the upper-left corner of the source rectangle.
sourceWidthintThe width of the source rectangle.
sourceHeightintThe height of the source rectangle.
opacityushortThe opacity of the blended image, where 0 is completely transparent and 256 is completely opaque.
Clear()
Clears the bitmap associated with this drawing context.
public void Clear()
Dispose()
Disposes of the bitmap and frees up any resources used by the object.
public void Dispose()
Dispose(bool)
Disposes of the bitmap and frees up any resources used by the object.
protected virtual void Dispose(bool disposing)
Parameters
disposingboolTrue for disposing.
DrawEllipse(Brush, Pen, int, int, int, int)
Draws an ellipse on the bitmap with the specified brush, pen, location, and radii.
public void DrawEllipse(Brush brush, Pen pen, int x, int y, int xRadius, int yRadius)
Parameters
brushBrushThe brush to fill the ellipse with.
penPenThe pen used to draw the outline of the ellipse.
xintThe x-coordinate of the upper-left corner of the ellipse.
yintThe y-coordinate of the upper-left corner of the ellipse.
xRadiusintThe x-radius of the ellipse.
yRadiusintThe y-radius of the ellipse.
DrawImage(Bitmap, int, int)
Draws an image on the bitmap at the specified location.
public void DrawImage(Bitmap source, int x, int y)
Parameters
sourceBitmapThe bitmap to draw.
xintThe x-coordinate of the upper-left corner of the image.
yintThe y-coordinate of the upper-left corner of the image.
DrawImage(Bitmap, int, int, int, int, int, int)
Draws a portion of the specified image on the bitmap at the specified location and with the specified size.
public void DrawImage(Bitmap source, int destinationX, int destinationY, int sourceX, int sourceY, int sourceWidth, int sourceHeight)
Parameters
sourceBitmapThe bitmap to draw a portion of.
destinationXintThe x-coordinate of the upper-left corner of the destination rectangle.
destinationYintThe y-coordinate of the upper-left corner of the destination rectangle.
sourceXintThe x-coordinate of the upper-left corner of the source rectangle.
sourceYintThe y-coordinate of the upper-left corner of the source rectangle.
sourceWidthintThe width of the source rectangle.
sourceHeightintThe height of the source rectangle.
DrawLine(Pen, int, int, int, int)
Draws a line with the specified pen between the specified points.
public void DrawLine(Pen pen, int x0, int y0, int x1, int y1)
Parameters
penPenThe pen to use to draw the line.
x0intThe x-coordinate of the start point of the line.
y0intThe y-coordinate of the start point of the line.
x1intThe x-coordinate of the end point of the line.
y1intThe y-coordinate of the end point of the line.
DrawPolygon(Brush, Pen, int[])
Draws a polygon with the specified brush and pen.
public void DrawPolygon(Brush brush, Pen pen, int[] pts)
Parameters
brushBrushThe brush to use to fill the polygon.
penPenThe pen to use to draw the polygon edges.
ptsint[]The points that define the vertices of the polygon.
DrawRectangle(Brush, Pen, int, int, int, int)
Draws a rectangle onto the bitmap using the specified brush and pen.
public void DrawRectangle(Brush brush, Pen pen, int x, int y, int width, int height)
Parameters
brushBrushThe brush to use for filling the rectangle.
penPenThe pen to use for outlining the rectangle.
xintThe x-coordinate of the top-left corner of the rectangle.
yintThe y-coordinate of the top-left corner of the rectangle.
widthintThe width of the rectangle.
heightintThe height of the rectangle.
DrawText(string, Font, Color, int, int)
Draws a text string with the specified font and color at the specified position.
public void DrawText(string text, Font font, Color color, int x, int y)
Parameters
textstringThe text string to draw.
fontFontThe font used to draw the text.
colorColorThe color used to draw the text.
xintThe x-coordinate of the upper-left corner of the text string.
yintThe y-coordinate of the upper-left corner of the text string.
DrawText(ref string, Font, Color, int, int, int, int, TextAlignment, TextTrimming)
Draws a text string with the specified font, color, width, and height at the specified position.
public bool DrawText(ref string text, Font font, Color color, int x, int y, int width, int height, TextAlignment alignment, TextTrimming trimming)
Parameters
textstringThe text string to draw.
fontFontThe font used to draw the text.
colorColorThe color used to draw the text.
xintThe x-coordinate of the upper-left corner of the text string.
yintThe y-coordinate of the upper-left corner of the text string.
widthintThe width of the text string.
heightintThe height of the text string.
alignmentTextAlignmentThe horizontal alignment of the text within the bounding rectangle.
trimmingTextTrimmingThe text trimming style to be applied to the text string.
Returns
- bool
True if the text string was drawn successfully; otherwise, false.
GetClippingRectangle(out int, out int, out int, out int)
Gets the clipping rectangle for the current context.
public void GetClippingRectangle(out int x, out int y, out int width, out int height)
Parameters
xintThe x-coordinate of the clipping rectangle.
yintThe y-coordinate of the clipping rectangle.
widthintThe width of the clipping rectangle.
heightintThe height of the clipping rectangle.
GetTranslation(out int, out int)
Retrieves the current translation of the drawing context.
public void GetTranslation(out int x, out int y)
Parameters
xintReceives the x component of the translation.
yintReceives the y component of the translation.
PopClippingRectangle()
Pops the top clipping rectangle from the stack.
public void PopClippingRectangle()
PushClippingRectangle(int, int, int, int)
Pushes a new clipping rectangle onto the stack.
public void PushClippingRectangle(int x, int y, int width, int height)
Parameters
xintThe x-coordinate of the clipping rectangle.
yintThe y-coordinate of the clipping rectangle.
widthintThe width of the clipping rectangle.
heightintThe height of the clipping rectangle.
RotateImage(int, int, int, Bitmap, int, int, int, int, ushort)
Rotates the specified source image by the specified angle and blends it onto the current bitmap at the specified location.
public void RotateImage(int angle, int destinationX, int destinationY, Bitmap bitmap, int sourceX, int sourceY, int sourceWidth, int sourceHeight, ushort opacity)
Parameters
angleintThe angle to rotate the source image, in degrees.
destinationXintThe x-coordinate of the upper-left corner of the destination rectangle.
destinationYintThe y-coordinate of the upper-left corner of the destination rectangle.
bitmapBitmapThe source image to rotate and blend onto the current bitmap.
sourceXintThe x-coordinate of the upper-left corner of the source rectangle.
sourceYintThe y-coordinate of the upper-left corner of the source rectangle.
sourceWidthintThe width of the source rectangle.
sourceHeightintThe height of the source rectangle.
opacityushortThe opacity of the blended image, where 0 is completely transparent and 256 is completely opaque.
Scale9Image(int, int, int, int, Bitmap, int, int, int, int, ushort)
Draws a scalable nine-patch image on the display, scaling the middle section to fit the specified rectangle.
public void Scale9Image(int xDst, int yDst, int widthDst, int heightDst, Bitmap bitmap, int leftBorder, int topBorder, int rightBorder, int bottomBorder, ushort opacity)
Parameters
xDstintThe x-coordinate of the upper-left corner of the destination rectangle.
yDstintThe y-coordinate of the upper-left corner of the destination rectangle.
widthDstintThe width of the destination rectangle.
heightDstintThe height of the destination rectangle.
bitmapBitmapThe source bitmap to draw.
leftBorderintThe width of the left border.
topBorderintThe height of the top border.
rightBorderintThe width of the right border.
bottomBorderintThe height of the bottom border.
opacityushortThe opacity of the image to draw, where 0 is fully transparent and 256 is fully opaque.
SetPixel(Color, int, int)
Sets the pixel at the specified coordinates to the specified color.
public void SetPixel(Color color, int x, int y)
Parameters
colorColorThe color to set the pixel to.
xintThe x-coordinate of the pixel.
yintThe y-coordinate of the pixel.
StretchImage(int, int, int, int, Bitmap, int, int, int, int, ushort)
Draws an image on the display, stretching it to fit the specified destination rectangle.
public void StretchImage(int xDst, int yDst, int widthDst, int heightDst, Bitmap bitmap, int xSrc, int ySrc, int widthSrc, int heightSrc, ushort opacity)
Parameters
xDstintThe x-coordinate of the upper-left corner of the destination rectangle.
yDstintThe y-coordinate of the upper-left corner of the destination rectangle.
widthDstintThe width of the destination rectangle.
heightDstintThe height of the destination rectangle.
bitmapBitmapThe source bitmap to draw.
xSrcintThe x-coordinate of the upper-left corner of the portion of the source bitmap to draw.
ySrcintThe y-coordinate of the upper-left corner of the portion of the source bitmap to draw.
widthSrcintThe width of the portion of the source bitmap to draw.
heightSrcintThe height of the portion of the source bitmap to draw.
opacityushortThe opacity of the image to draw, where 0 is fully transparent and 256 is fully opaque.
TileImage(int, int, Bitmap, int, int, ushort)
Draws an image repeatedly on the display, tiling it to fill the specified rectangle.
public void TileImage(int xDst, int yDst, Bitmap bitmap, int width, int height, ushort opacity)
Parameters
xDstintThe x-coordinate of the upper-left corner of the destination rectangle.
yDstintThe y-coordinate of the upper-left corner of the destination rectangle.
bitmapBitmapThe source bitmap to tile.
widthintThe width of the destination rectangle.
heightintThe height of the destination rectangle.
opacityushortThe opacity of the image to draw, where 0 is fully transparent and 256 is fully opaque.
Translate(int, int)
Translates the drawing context by a specified amount.
public void Translate(int dx, int dy)