TextureView.LockCanvas Method

Definition

Overloads

LockCanvas(Rect)

Just like #lockCanvas() but allows specification of a dirty rectangle.

LockCanvas()

Start editing the pixels in the surface.

LockCanvas(Rect)

Just like #lockCanvas() but allows specification of a dirty rectangle.

[Android.Runtime.Register("lockCanvas", "(Landroid/graphics/Rect;)Landroid/graphics/Canvas;", "GetLockCanvas_Landroid_graphics_Rect_Handler")]
public virtual Android.Graphics.Canvas? LockCanvas (Android.Graphics.Rect? dirty);
[<Android.Runtime.Register("lockCanvas", "(Landroid/graphics/Rect;)Landroid/graphics/Canvas;", "GetLockCanvas_Landroid_graphics_Rect_Handler")>]
abstract member LockCanvas : Android.Graphics.Rect -> Android.Graphics.Canvas
override this.LockCanvas : Android.Graphics.Rect -> Android.Graphics.Canvas

Parameters

dirty
Rect

Area of the surface that will be modified. If null the area of the entire surface is used.

Returns

A Canvas used to draw into the surface, or null if the surface cannot be locked for drawing (see #isAvailable()).

Attributes

Remarks

Just like #lockCanvas() but allows specification of a dirty rectangle. Every pixel within that rectangle must be written; however pixels outside the dirty rectangle will be preserved by the next call to lockCanvas().

This method can return null if the underlying surface texture is not available (see #isAvailable() or if the surface texture is already connected to an image producer (for instance: the camera, OpenGL, a media player, etc.)

Java documentation for android.view.TextureView.lockCanvas(android.graphics.Rect).

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.

See also

Applies to

LockCanvas()

Start editing the pixels in the surface.

[Android.Runtime.Register("lockCanvas", "()Landroid/graphics/Canvas;", "GetLockCanvasHandler")]
public virtual Android.Graphics.Canvas? LockCanvas ();
[<Android.Runtime.Register("lockCanvas", "()Landroid/graphics/Canvas;", "GetLockCanvasHandler")>]
abstract member LockCanvas : unit -> Android.Graphics.Canvas
override this.LockCanvas : unit -> Android.Graphics.Canvas

Returns

A Canvas used to draw into the surface, or null if the surface cannot be locked for drawing (see #isAvailable()).

Attributes

Remarks

Start editing the pixels in the surface. The returned Canvas can be used to draw into the surface's bitmap. A null is returned if the surface has not been created or otherwise cannot be edited. You will usually need to implement SurfaceTextureListener#onSurfaceTextureAvailable(android.graphics.SurfaceTexture, int, int) to find out when the Surface is available for use.

The content of the Surface is never preserved between unlockCanvas() and lockCanvas(), for this reason, every pixel within the Surface area must be written. The only exception to this rule is when a dirty rectangle is specified, in which case, non-dirty pixels will be preserved.

This method can only be used if the underlying surface is not already owned by another producer. For instance, if the TextureView is being used to render the camera's preview you cannot invoke this method.

Java documentation for android.view.TextureView.lockCanvas().

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.

See also

Applies to