Android Guides | Samples

Android.Graphics.Canvas Class

The Canvas class holds the "draw" calls.

See Also: Canvas

Syntax

[Android.Runtime.Register("android/graphics/Canvas", DoNotGenerateAcw=true)]
public class Canvas : Object

Remarks

The Canvas class holds the "draw" calls. To draw something, you need 4 basic components: A Bitmap to hold the pixels, a Canvas to host the draw calls (writing into the bitmap), a drawing primitive (e.g. Rect, Path, text, Bitmap), and a paint (to describe the colors and styles for the drawing).

Developer Guides

For more information about how to use Canvas, read the Canvas and Drawables developer guide.

[Android Documentation]

Requirements

Namespace: Android.Graphics
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions: 0.0.0.0
Since: Added in API level 1

The members of Android.Graphics.Canvas are listed below.

See Also: Object

Public Constructors

Construct an empty raster canvas.
Construct a canvas with the specified bitmap to draw into.

Protected Constructors

A constructor used when creating managed representations of JNI objects; called by the runtime.

Public Properties

[read-only]
ClipBoundsRect. Retrieve the bounds of the current clip (in local coordinates).
DensityInt32.
DrawFilterDrawFilter.
[read-only]
GLIGL.
[read-only]
HeightInt32. Returns the height of the current drawing layer
[read-only]
IsHardwareAcceleratedBoolean. Indicates whether this Canvas uses hardware acceleration.
[read-only]
IsOpaqueBoolean. Return true if the device that the current layer draws into is opaque (i.e. does not support per-pixel alpha).
MatrixMatrix. Return a new matrix with a copy of the canvas' current transformation matrix.
[read-only]
MaximumBitmapHeightInt32. Returns the maximum allowed height for bitmaps drawn with this canvas.
[read-only]
MaximumBitmapWidthInt32. Returns the maximum allowed width for bitmaps drawn with this canvas.
[read-only]
SaveCountInt32. Returns the number of matrix/clip states on the Canvas' private stack.
[read-only]
WidthInt32. Returns the width of the current drawing layer

Protected Properties

[read-only]
override
ThresholdClassIntPtr. This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.
[read-only]
override
ThresholdTypeType. This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

Public Methods

ClipPath(Path) : Boolean
Intersect the current clip with the specified path.
ClipPath(Path, Region+Op) : Boolean
Modify the current clip with the specified path.
ClipRect(Rect) : Boolean
Intersect the current clip with the specified rectangle, which is expressed in local coordinates.
ClipRect(RectF) : Boolean
Intersect the current clip with the specified rectangle, which is expressed in local coordinates.
ClipRect(Rect, Region+Op) : Boolean
Modify the current clip with the specified rectangle, which is expressed in local coordinates.
ClipRect(RectF, Region+Op) : Boolean
Modify the current clip with the specified rectangle.
ClipRect(Int32, Int32, Int32, Int32) : Boolean
Intersect the current clip with the specified rectangle, which is expressed in local coordinates.
ClipRect(Single, Single, Single, Single) : Boolean
Intersect the current clip with the specified rectangle, which is expressed in local coordinates.
ClipRect(Single, Single, Single, Single, Region+Op) : Boolean
Modify the current clip with the specified rectangle, which is expressed in local coordinates.
ClipRegion(Region) : Boolean
Intersect the current clip with the specified region.
ClipRegion(Region, Region+Op) : Boolean
Modify the current clip with the specified region.
Concat(Matrix)
Preconcat the current matrix with the specified matrix.
DrawArc(RectF, Single, Single, Boolean, Paint)
DrawArc(Single, Single, Single, Single, Single, Single, Boolean, Paint)
DrawARGB(Int32, Int32, Int32, Int32)
Fill the entire canvas' bitmap (restricted to the current clip) with the specified ARGB color, using srcover porterduff mode.
DrawBitmap(Bitmap, Matrix, Paint)
Draw the bitmap using the specified matrix.
DrawBitmap(Bitmap, Rect, Rect, Paint)
Draw the specified bitmap, scaling/translating automatically to fill the destination rectangle.
DrawBitmap(Bitmap, Rect, RectF, Paint)
Draw the specified bitmap, scaling/translating automatically to fill the destination rectangle.
DrawBitmap(Bitmap, Single, Single, Paint)
Draw the specified bitmap, with its top/left corner at (x,y), using the specified paint, transformed by the current matrix.
DrawBitmap(Int32[], Int32, Int32, Int32, Int32, Int32, Int32, Boolean, Paint)
Legacy version of drawBitmap(int[] colors, ...) that took ints for x,y
DrawBitmap(Int32[], Int32, Int32, Single, Single, Int32, Int32, Boolean, Paint)
Treat the specified array of colors as a bitmap, and draw it.
DrawBitmapMesh(Bitmap, Int32, Int32, Single[], Int32, Int32[], Int32, Paint)
Draw the bitmap through the mesh, where mesh vertices are evenly distributed across the bitmap.
DrawCircle(Single, Single, Single, Paint)
Draw the specified circle using the specified paint.
DrawColor(Color)
Fill the entire canvas' bitmap (restricted to the current clip) with the specified color, using srcover porterduff mode.
DrawColor(Color, PorterDuff+Mode)
Fill the entire canvas' bitmap (restricted to the current clip) with the specified color and porter-duff xfermode.
DrawLine(Single, Single, Single, Single, Paint)
Draw a line segment with the specified start and stop x,y coordinates, using the specified paint.
DrawLines(Single[], Paint)
DrawLines(Single[], Int32, Int32, Paint)
Draw a series of lines.
DrawOval(RectF, Paint)
Draw the specified oval using the specified paint.
DrawOval(Single, Single, Single, Single, Paint)
Draw the specified oval using the specified paint.
DrawPaint(Paint)
Fill the entire canvas' bitmap (restricted to the current clip) with the specified paint.
DrawPath(Path, Paint)
Draw the specified path using the specified paint.
DrawPicture(Picture)
Save the canvas state, draw the picture, and restore the canvas state.
DrawPicture(Picture, Rect)
Draw the picture, stretched to fit into the dst rectangle.
DrawPicture(Picture, RectF)
Draw the picture, stretched to fit into the dst rectangle.
DrawPoint(Single, Single, Paint)
Helper for drawPoints() for drawing a single point.
DrawPoints(Single[], Paint)
Helper for drawPoints() that assumes you want to draw the entire array
DrawPoints(Single[], Int32, Int32, Paint)
Draw a series of points.
DrawPosText(String, Single[], Paint)
Draw the text in the array, with each character's origin specified by the pos array.
DrawPosText(Char[], Int32, Int32, Single[], Paint)
Draw the text in the array, with each character's origin specified by the pos array.
DrawRect(Rect, Paint)
Draw the specified Rect using the specified Paint.
DrawRect(RectF, Paint)
Draw the specified Rect using the specified paint.
DrawRect(Single, Single, Single, Single, Paint)
Draw the specified Rect using the specified paint.
DrawRGB(Int32, Int32, Int32)
Fill the entire canvas' bitmap (restricted to the current clip) with the specified RGB color, using srcover porterduff mode.
DrawRoundRect(RectF, Single, Single, Paint)
Draw the specified round-rect using the specified paint.
DrawRoundRect(Single, Single, Single, Single, Single, Single, Paint)
Draw the specified round-rect using the specified paint.
DrawText(String, Single, Single, Paint)
Draw the text, with origin at (x,y), using the specified paint.
DrawText(ICharSequence, Int32, Int32, Single, Single, Paint)
Draw the specified range of text, specified by start/end, with its origin at (x,y), in the specified Paint.
DrawText(Char[], Int32, Int32, Single, Single, Paint)
Draw the text, with origin at (x,y), using the specified paint.
DrawText(String, Int32, Int32, Single, Single, Paint)
Draw the text, with origin at (x,y), using the specified paint.
DrawTextOnPath(String, Path, Single, Single, Paint)
Draw the text, with origin at (x,y), using the specified paint, along the specified path.
DrawTextOnPath(Char[], Int32, Int32, Path, Single, Single, Paint)
Draw the text, with origin at (x,y), using the specified paint, along the specified path.
DrawVertices(Canvas+VertexMode, Int32, Single[], Int32, Single[], Int32, Int32[], Int32, Int16[], Int32, Int32, Paint)
Draw the array of vertices, interpreted as triangles (based on mode).
static
FreeGlCaches()
GetClipBounds(Rect) : Boolean
Return the bounds of the current clip (in local coordinates) in the bounds parameter, and return true if it is non-empty.
GetMatrix(Matrix)
Return, in ctm, the current transformation matrix.
QuickReject(Path, Canvas+EdgeType) : Boolean
Return true if the specified path, after being transformed by the current matrix, would lie completely outside of the current clip.
QuickReject(RectF, Canvas+EdgeType) : Boolean
Return true if the specified rectangle, after being transformed by the current matrix, would lie completely outside of the current clip.
QuickReject(Single, Single, Single, Single, Canvas+EdgeType) : Boolean
Return true if the specified rectangle, after being transformed by the current matrix, would lie completely outside of the current clip.
Restore()
This call balances a previous call to save(), and is used to remove all modifications to the matrix/clip state since the last save call.
RestoreToCount(Int32)
Efficient way to pop any calls to save() that happened after the save count reached saveCount.
Rotate(Single)
Preconcat the current matrix with the specified rotation.
Rotate(Single, Single, Single)
Preconcat the current matrix with the specified rotation.
Save() : Int32
Saves the current matrix and clip onto a private stack.
Save(SaveFlags) : Int32
Based on saveFlags, can save the current matrix and clip onto a private stack.
SaveLayer(RectF, Paint) : Int32
Convenience for saveLayer(bounds, paint, Canvas.ALL_SAVE_FLAG)
SaveLayer(RectF, Paint, SaveFlags) : Int32
This behaves the same as save(), but in addition it allocates and redirects drawing to an offscreen bitmap.
SaveLayer(Single, Single, Single, Single, Paint) : Int32
Convenience for saveLayer(left, top, right, bottom, paint, Canvas.ALL_SAVE_FLAG)
SaveLayer(Single, Single, Single, Single, Paint, SaveFlags) : Int32
Helper version of saveLayer() that takes 4 values rather than a RectF.
SaveLayerAlpha(RectF, Int32) : Int32
Convenience for saveLayerAlpha(bounds, alpha, Canvas.ALL_SAVE_FLAG)
SaveLayerAlpha(RectF, Int32, SaveFlags) : Int32
This behaves the same as save(), but in addition it allocates and redirects drawing to an offscreen bitmap.
SaveLayerAlpha(Single, Single, Single, Single, Int32) : Int32
Helper for saveLayerAlpha(left, top, right, bottom, alpha, Canvas.ALL_SAVE_FLAG)
SaveLayerAlpha(Single, Single, Single, Single, Int32, SaveFlags) : Int32
Helper for saveLayerAlpha() that takes 4 values instead of a RectF.
Scale(Single, Single)
Preconcat the current matrix with the specified scale.
Scale(Single, Single, Single, Single)
Preconcat the current matrix with the specified scale.
SetBitmap(Bitmap)
Specify a bitmap for the canvas to draw into.
SetViewport(Int32, Int32)
Skew(Single, Single)
Preconcat the current matrix with the specified skew.
Translate(Single, Single)
Preconcat the current matrix with the specified translation