saveLayer

fun saveLayer(left: Float, top: Float, right: Float, bottom: Float, paint: Paint?): Int


fun saveLayer(bounds: Rect?, paint: Paint?): Int

Saves Matrix and clip, and allocates a Bitmap for subsequent drawing. Calling restore() discards changes to Matrix and clip, and draws the Bitmap.

Matrix may be changed by translate(), scale(), rotate(), skew(), concat(), setMatrix(), and resetMatrix(). Clip may be changed by clipRect(), clipRRect(), clipPath(), clipRegion().

Rect bounds suggests but does not define the Bitmap size. To clip drawing to a specific rectangle, use clipRect().

Optional Paint paint applies alpha, ColorFilter, ImageFilter, and BlendMode when restore() is called.

Call restoreToCount() with returned value to restore this and subsequent saves.

Return

depth of saved stack

Parameters

bounds

hint to limit the size of the layer

paint

graphics state for layer; may be null

See also