Canvas Class

Definition

The Canvas class holds the "draw" calls.

[Android.Runtime.Register("android/graphics/Canvas", ApiSince=1, DoNotGenerateAcw=true)]
public class Canvas : Java.Lang.Object
type Canvas = class
    inherit Object
Inheritance
Canvas
Attributes

Remarks

Android platform documentation

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Constructors

Canvas()

Construct an empty raster canvas.

Canvas(Bitmap)

Construct a canvas with the specified bitmap to draw into.

Canvas(IGL)
Canvas(IntPtr, JniHandleOwnership)

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

Properties

Class

Returns the unique instance of Class that represents this object's class.

(Inherited from Object)
ClipBounds

Retrieve the bounds of the current clip (in local coordinates).

Density
DrawFilter
GL
Handle

The handle to the underlying Android instance.

(Inherited from Object)
Height

Returns the height of the current drawing layer

IsHardwareAccelerated

Indicates whether this Canvas uses hardware acceleration.

IsOpaque

Return true if the device that the current layer draws into is opaque (i.e. does not support per-pixel alpha).

JniIdentityHashCode (Inherited from Object)
JniPeerMembers
Matrix

Return a new matrix with a copy of the canvas' current transformation matrix.

MaximumBitmapHeight

Returns the maximum allowed height for bitmaps drawn with this canvas.

MaximumBitmapWidth

Returns the maximum allowed width for bitmaps drawn with this canvas.

PeerReference (Inherited from Object)
SaveCount

Returns the number of matrix/clip states on the Canvas' private stack.

ThresholdClass

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

ThresholdType

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

Width

Returns the width of the current drawing layer

Methods

ClipOutPath(Path)
ClipOutRect(Int32, Int32, Int32, Int32)
ClipOutRect(Rect)
ClipOutRect(RectF)
ClipOutRect(Single, Single, Single, Single)
ClipPath(Path)

Intersect the current clip with the specified path.

ClipPath(Path, Region+Op)
Obsolete.

Modify the current clip with the specified path.

ClipRect(Int32, Int32, Int32, Int32)

Intersect the current clip with the specified rectangle, which is expressed in local coordinates.

ClipRect(Rect)

Intersect the current clip with the specified rectangle, which is expressed in local coordinates.

ClipRect(Rect, Region+Op)
Obsolete.

Modify the current clip with the specified rectangle, which is expressed in local coordinates.

ClipRect(RectF)

Intersect the current clip with the specified rectangle, which is expressed in local coordinates.

ClipRect(RectF, Region+Op)
Obsolete.

Modify the current clip with the specified rectangle.

ClipRect(Single, Single, Single, Single)

Intersect the current clip with the specified rectangle, which is expressed in local coordinates.

ClipRect(Single, Single, Single, Single, Region+Op)
Obsolete.

Modify the current clip with the specified rectangle, which is expressed in local coordinates.

ClipRegion(Region)
Obsolete.

Intersect the current clip with the specified region.

ClipRegion(Region, Region+Op)
Obsolete.

Modify the current clip with the specified region.

Clone()

Creates and returns a copy of this Object.

(Inherited from Object)
Concat(Matrix)

Preconcat the current matrix with the specified matrix.

Dispose() (Inherited from Object)
Dispose(Boolean) (Inherited from Object)
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)
Obsolete.

Legacy version of drawBitmap(int[] colors, ...) that took ints for x,y

DrawBitmap(Int32[], Int32, Int32, Single, Single, Int32, Int32, Boolean, Paint)
Obsolete.

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[], Int32, Int32, Paint)

Draw a series of lines.

DrawLines(Single[], Paint)
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[], Int32, Int32, Paint)

Draw a series of points.

DrawPoints(Single[], Paint)

Helper for drawPoints() that assumes you want to draw the entire array

DrawPosText(Char[], Int32, Int32, Single[], Paint)
Obsolete.

Draw the text in the array, with each character's origin specified by the pos array.

DrawPosText(String, Single[], Paint)
Obsolete.

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(Char[], Int32, Int32, 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(String, Int32, Int32, Single, Single, Paint)

Draw the text, with origin at (x,y), using the specified paint.

DrawText(String, Single, Single, Paint)

Draw the text, with origin at (x,y), using the specified paint.

DrawTextOnPath(Char[], Int32, Int32, Path, Single, Single, Paint)

Draw the text, with origin at (x,y), using the specified paint, along the specified path.

DrawTextOnPath(String, Path, Single, Single, Paint)

Draw the text, with origin at (x,y), using the specified paint, along the specified path.

DrawTextRun(Char[], Int32, Int32, Int32, Int32, Single, Single, Boolean, Paint)
DrawTextRun(ICharSequence, Int32, Int32, Int32, Int32, Single, Single, Boolean, Paint)
DrawTextRun(String, Int32, Int32, Int32, Int32, Single, Single, Boolean, Paint)
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).

Equals(Object)

Compares this instance with the specified object and indicates if they are equal.

(Inherited from Object)
FreeGlCaches()
GetClipBounds(Rect)

Return the bounds of the current clip (in local coordinates) in the bounds parameter, and return true if it is non-empty.

GetHashCode()

Returns an integer hash code for this object.

(Inherited from Object)
GetMatrix(Matrix)
Obsolete.

Return, in ctm, the current transformation matrix.

JavaFinalize()

Invoked when the garbage collector has detected that this instance is no longer reachable.

(Inherited from Object)
Notify()

Causes a thread which is waiting on this object's monitor (by means of calling one of the wait() methods) to be woken up.

(Inherited from Object)
NotifyAll()

Causes all threads which are waiting on this object's monitor (by means of calling one of the wait() methods) to be woken up.

(Inherited from Object)
QuickReject(Path, Canvas+EdgeType)

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)

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)

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()

Saves the current matrix and clip onto a private stack.

Save(SaveFlags)
Obsolete.

Based on saveFlags, can save the current matrix and clip onto a private stack.

SaveLayer(RectF, Paint)

Android.Graphics.Canvas.ALL_SAVE_FLAG

SaveLayer(RectF, Paint, SaveFlags)
Obsolete.

This behaves the same as save(), but in addition it allocates and redirects drawing to an offscreen bitmap.

SaveLayer(Single, Single, Single, Single, Paint)

Android.Graphics.Canvas.ALL_SAVE_FLAG

SaveLayer(Single, Single, Single, Single, Paint, SaveFlags)
Obsolete.

Helper version of saveLayer() that takes 4 values rather than a RectF.

SaveLayerAlpha(RectF, Int32)

Android.Graphics.Canvas.ALL_SAVE_FLAG

SaveLayerAlpha(RectF, Int32, SaveFlags)
Obsolete.

This behaves the same as save(), but in addition it allocates and redirects drawing to an offscreen bitmap.

SaveLayerAlpha(Single, Single, Single, Single, Int32)

Android.Graphics.Canvas.ALL_SAVE_FLAG

SaveLayerAlpha(Single, Single, Single, Single, Int32, SaveFlags)
Obsolete.

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.

SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
SetViewport(Int32, Int32)
Skew(Single, Single)

Preconcat the current matrix with the specified skew.

ToArray<T>() (Inherited from Object)
ToString()

Returns a string containing a concise, human-readable description of this object.

(Inherited from Object)
Translate(Single, Single)

Preconcat the current matrix with the specified translation

UnregisterFromRuntime() (Inherited from Object)
Wait()

Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object.

(Inherited from Object)
Wait(Int64)

Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object or until the specified timeout expires.

(Inherited from Object)
Wait(Int64, Int32)

Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object or until the specified timeout expires.

(Inherited from Object)

Explicit Interface Implementations

IJavaObjectEx.IsProxy (Inherited from Object)
IJavaObjectEx.KeyHandle (Inherited from Object)
IJavaObjectEx.NeedsActivation (Inherited from Object)
IJavaObjectEx.ToLocalJniHandle() (Inherited from Object)
IJavaPeerable.Disposed() (Inherited from Object)
IJavaPeerable.DisposeUnlessReferenced() (Inherited from Object)
IJavaPeerable.Finalized() (Inherited from Object)
IJavaPeerable.JniManagedPeerState (Inherited from Object)
IJavaPeerable.SetJniIdentityHashCode(Int32) (Inherited from Object)
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) (Inherited from Object)
IJavaPeerable.SetPeerReference(JniObjectReference) (Inherited from Object)

Extension Methods

JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject)
GetJniTypeName(IJavaPeerable)

Applies to