public class Picture extends Object
Canvas through Canvas#drawPicture.
The recorded drawing calls can be played back via Canvas#drawPicture. Drawing objects using a
Picture instance can be faster than calling equivalent methods. This approach is applicable to the scenario where
some objects need to be drawn for multiple times.
| 构造器 | 说明 |
|---|---|
Picture() |
A constructor used to create a
Picture instance. |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
Canvas |
beginRecording(int width,
int height) |
Starts recording.
|
void |
draw(Canvas canvas) |
Draws the object on the specified canvas.
|
void |
endRecording() |
Ends recording.
|
int |
getHeight() |
Obtains the height of this picture.
|
int |
getWidth() |
Obtains the width of this picture.
|
public Canvas beginRecording(int width, int height)
After you call this method, a Canvas instance used for recording drawing operations will be returned.
This method must be used together with Picture#endRecording.
width - Indicates the width of the picture whose coordinate in the upper left corner starts from (0,0). The
drawing that exceeds the width may or may not be drawn.height - Indicates the height of the picture whose coordinate in the upper left corner starts from (0,0).
The drawing that exceeds the height may or may not be drawn.Canvas instance that records drawing calls. All drawings in the Canvas are
stored in this Picture.public void endRecording()
All recording operations must start with beginRecording(int, int) and end with endRecording().
public int getWidth()
public int getHeight()
public void draw(Canvas canvas)
canvas - Indicates the canvas.