Search Results for

    Show / Hide Table of Contents

    Class DrawingContext

    Drawing Context.

    Inheritance
    object
    DispatcherObject
    DrawingContext
    Implements
    IDisposable
    Inherited Members
    DispatcherObject.Dispatcher
    DispatcherObject.CheckAccess()
    DispatcherObject.VerifyAccess()
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    Namespace: nanoFramework.Presentation.Media
    Assembly: nanoFramework.Graphics.dll
    Syntax
    public class DrawingContext : DispatcherObject, IDisposable

    Constructors

    DrawingContext(int, int)

    Creates a drawing context for an empty bitmap of a specific width and height.

    Declaration
    public DrawingContext(int width, int height)
    Parameters
    Type Name Description
    int width

    The target width of the bitmap.

    int height

    The target height of the bitmap.

    DrawingContext(Bitmap)

    Creates a drawing context for the specified bitmap.

    Declaration
    public DrawingContext(Bitmap bmp)
    Parameters
    Type Name Description
    Bitmap bmp

    The bitmap.

    Properties

    Bitmap

    Gets the bitmap associated with this drawing context.

    Declaration
    public Bitmap Bitmap { get; }
    Property Value
    Type Description
    Bitmap

    Height

    Gets the height of the bitmap.

    Declaration
    public int Height { get; }
    Property Value
    Type Description
    int

    Width

    Gets the width of the bitmap.

    Declaration
    public int Width { get; }
    Property Value
    Type Description
    int

    Methods

    BlendImage(Bitmap, int, int, int, int, int, int, ushort)

    Blends the specified source image onto the current bitmap at the specified location.

    Declaration
    public void BlendImage(Bitmap source, int destinationX, int destinationY, int sourceX, int sourceY, int sourceWidth, int sourceHeight, ushort opacity)
    Parameters
    Type Name Description
    Bitmap source

    The source image to blend onto the current bitmap.

    int destinationX

    The x-coordinate of the upper-left corner of the destination rectangle.

    int destinationY

    The y-coordinate of the upper-left corner of the destination rectangle.

    int sourceX

    The x-coordinate of the upper-left corner of the source rectangle.

    int sourceY

    The y-coordinate of the upper-left corner of the source rectangle.

    int sourceWidth

    The width of the source rectangle.

    int sourceHeight

    The height of the source rectangle.

    ushort opacity

    The opacity of the blended image, where 0 is completely transparent and 256 is completely opaque.

    Clear()

    Clears the bitmap associated with this drawing context.

    Declaration
    public void Clear()

    Dispose()

    Disposes of the bitmap and frees up any resources used by the object.

    Declaration
    public void Dispose()

    Dispose(bool)

    Disposes of the bitmap and frees up any resources used by the object.

    Declaration
    protected virtual void Dispose(bool disposing)
    Parameters
    Type Name Description
    bool disposing

    True for disposing.

    DrawEllipse(Brush, Pen, int, int, int, int)

    Draws an ellipse on the bitmap with the specified brush, pen, location, and radii.

    Declaration
    public void DrawEllipse(Brush brush, Pen pen, int x, int y, int xRadius, int yRadius)
    Parameters
    Type Name Description
    Brush brush

    The brush to fill the ellipse with.

    Pen pen

    The pen used to draw the outline of the ellipse.

    int x

    The x-coordinate of the upper-left corner of the ellipse.

    int y

    The y-coordinate of the upper-left corner of the ellipse.

    int xRadius

    The x-radius of the ellipse.

    int yRadius

    The y-radius of the ellipse.

    DrawImage(Bitmap, int, int)

    Draws an image on the bitmap at the specified location.

    Declaration
    public void DrawImage(Bitmap source, int x, int y)
    Parameters
    Type Name Description
    Bitmap source

    The bitmap to draw.

    int x

    The x-coordinate of the upper-left corner of the image.

    int y

    The 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.

    Declaration
    public void DrawImage(Bitmap source, int destinationX, int destinationY, int sourceX, int sourceY, int sourceWidth, int sourceHeight)
    Parameters
    Type Name Description
    Bitmap source

    The bitmap to draw a portion of.

    int destinationX

    The x-coordinate of the upper-left corner of the destination rectangle.

    int destinationY

    The y-coordinate of the upper-left corner of the destination rectangle.

    int sourceX

    The x-coordinate of the upper-left corner of the source rectangle.

    int sourceY

    The y-coordinate of the upper-left corner of the source rectangle.

    int sourceWidth

    The width of the source rectangle.

    int sourceHeight

    The height of the source rectangle.

    DrawLine(Pen, int, int, int, int)

    Draws a line with the specified pen between the specified points.

    Declaration
    public void DrawLine(Pen pen, int x0, int y0, int x1, int y1)
    Parameters
    Type Name Description
    Pen pen

    The pen to use to draw the line.

    int x0

    The x-coordinate of the start point of the line.

    int y0

    The y-coordinate of the start point of the line.

    int x1

    The x-coordinate of the end point of the line.

    int y1

    The y-coordinate of the end point of the line.

    DrawPolygon(Brush, Pen, int[])

    Draws a polygon with the specified brush and pen.

    Declaration
    public void DrawPolygon(Brush brush, Pen pen, int[] pts)
    Parameters
    Type Name Description
    Brush brush

    The brush to use to fill the polygon.

    Pen pen

    The pen to use to draw the polygon edges.

    int[] pts

    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.

    Declaration
    public void DrawRectangle(Brush brush, Pen pen, int x, int y, int width, int height)
    Parameters
    Type Name Description
    Brush brush

    The brush to use for filling the rectangle.

    Pen pen

    The pen to use for outlining the rectangle.

    int x

    The x-coordinate of the top-left corner of the rectangle.

    int y

    The y-coordinate of the top-left corner of the rectangle.

    int width

    The width of the rectangle.

    int height

    The height of the rectangle.

    DrawText(string, Font, Color, int, int)

    Draws a text string with the specified font and color at the specified position.

    Declaration
    public void DrawText(string text, Font font, Color color, int x, int y)
    Parameters
    Type Name Description
    string text

    The text string to draw.

    Font font

    The font used to draw the text.

    Color color

    The color used to draw the text.

    int x

    The x-coordinate of the upper-left corner of the text string.

    int y

    The 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.

    Declaration
    public bool DrawText(ref string text, Font font, Color color, int x, int y, int width, int height, TextAlignment alignment, TextTrimming trimming)
    Parameters
    Type Name Description
    string text

    The text string to draw.

    Font font

    The font used to draw the text.

    Color color

    The color used to draw the text.

    int x

    The x-coordinate of the upper-left corner of the text string.

    int y

    The y-coordinate of the upper-left corner of the text string.

    int width

    The width of the text string.

    int height

    The height of the text string.

    TextAlignment alignment

    The horizontal alignment of the text within the bounding rectangle.

    TextTrimming trimming

    The text trimming style to be applied to the text string.

    Returns
    Type Description
    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.

    Declaration
    public void GetClippingRectangle(out int x, out int y, out int width, out int height)
    Parameters
    Type Name Description
    int x

    The x-coordinate of the clipping rectangle.

    int y

    The y-coordinate of the clipping rectangle.

    int width

    The width of the clipping rectangle.

    int height

    The height of the clipping rectangle.

    GetTranslation(out int, out int)

    Retrieves the current translation of the drawing context.

    Declaration
    public void GetTranslation(out int x, out int y)
    Parameters
    Type Name Description
    int x

    Receives the x component of the translation.

    int y

    Receives the y component of the translation.

    PopClippingRectangle()

    Pops the top clipping rectangle from the stack.

    Declaration
    public void PopClippingRectangle()

    PushClippingRectangle(int, int, int, int)

    Pushes a new clipping rectangle onto the stack.

    Declaration
    public void PushClippingRectangle(int x, int y, int width, int height)
    Parameters
    Type Name Description
    int x

    The x-coordinate of the clipping rectangle.

    int y

    The y-coordinate of the clipping rectangle.

    int width

    The width of the clipping rectangle.

    int height

    The 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.

    Declaration
    public void RotateImage(int angle, int destinationX, int destinationY, Bitmap bitmap, int sourceX, int sourceY, int sourceWidth, int sourceHeight, ushort opacity)
    Parameters
    Type Name Description
    int angle

    The angle to rotate the source image, in degrees.

    int destinationX

    The x-coordinate of the upper-left corner of the destination rectangle.

    int destinationY

    The y-coordinate of the upper-left corner of the destination rectangle.

    Bitmap bitmap

    The source image to rotate and blend onto the current bitmap.

    int sourceX

    The x-coordinate of the upper-left corner of the source rectangle.

    int sourceY

    The y-coordinate of the upper-left corner of the source rectangle.

    int sourceWidth

    The width of the source rectangle.

    int sourceHeight

    The height of the source rectangle.

    ushort opacity

    The 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.

    Declaration
    public void Scale9Image(int xDst, int yDst, int widthDst, int heightDst, Bitmap bitmap, int leftBorder, int topBorder, int rightBorder, int bottomBorder, ushort opacity)
    Parameters
    Type Name Description
    int xDst

    The x-coordinate of the upper-left corner of the destination rectangle.

    int yDst

    The y-coordinate of the upper-left corner of the destination rectangle.

    int widthDst

    The width of the destination rectangle.

    int heightDst

    The height of the destination rectangle.

    Bitmap bitmap

    The source bitmap to draw.

    int leftBorder

    The width of the left border.

    int topBorder

    The height of the top border.

    int rightBorder

    The width of the right border.

    int bottomBorder

    The height of the bottom border.

    ushort opacity

    The 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.

    Declaration
    public void SetPixel(Color color, int x, int y)
    Parameters
    Type Name Description
    Color color

    The color to set the pixel to.

    int x

    The x-coordinate of the pixel.

    int y

    The 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.

    Declaration
    public void StretchImage(int xDst, int yDst, int widthDst, int heightDst, Bitmap bitmap, int xSrc, int ySrc, int widthSrc, int heightSrc, ushort opacity)
    Parameters
    Type Name Description
    int xDst

    The x-coordinate of the upper-left corner of the destination rectangle.

    int yDst

    The y-coordinate of the upper-left corner of the destination rectangle.

    int widthDst

    The width of the destination rectangle.

    int heightDst

    The height of the destination rectangle.

    Bitmap bitmap

    The source bitmap to draw.

    int xSrc

    The x-coordinate of the upper-left corner of the portion of the source bitmap to draw.

    int ySrc

    The y-coordinate of the upper-left corner of the portion of the source bitmap to draw.

    int widthSrc

    The width of the portion of the source bitmap to draw.

    int heightSrc

    The height of the portion of the source bitmap to draw.

    ushort opacity

    The 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.

    Declaration
    public void TileImage(int xDst, int yDst, Bitmap bitmap, int width, int height, ushort opacity)
    Parameters
    Type Name Description
    int xDst

    The x-coordinate of the upper-left corner of the destination rectangle.

    int yDst

    The y-coordinate of the upper-left corner of the destination rectangle.

    Bitmap bitmap

    The source bitmap to tile.

    int width

    The width of the destination rectangle.

    int height

    The height of the destination rectangle.

    ushort opacity

    The 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.

    Declaration
    public void Translate(int dx, int dy)
    Parameters
    Type Name Description
    int dx

    The amount to translate in the x direction.

    int dy

    The amount to translate in the y direction.

    Implements

    IDisposable

    Extension Methods

    LogDispatcher.GetCurrentClassLogger(object)
    LogDispatcher.GetCurrentClassLogger(object)
    LogDispatcher.GetCurrentClassLogger(object)
    LogDispatcher.GetCurrentClassLogger(object)
    LogDispatcher.GetCurrentClassLogger(object)
    LogDispatcher.GetCurrentClassLogger(object)
    LogDispatcher.GetCurrentClassLogger(object)
    LogDispatcher.GetCurrentClassLogger(object)
    LogDispatcher.GetCurrentClassLogger(object)
    LogDispatcher.GetCurrentClassLogger(object)
    In This Article
    Back to top Copyright © 2023 nanoFramework Contributors
    Generated by DocFX