Methods Summary |
---|
public Canvas | beginRecording(int width, int height)To record a picture, call beginRecording() and then draw into the Canvas
that is returned. Nothing we appear on screen, but all of the draw
commands (e.g. drawRect(...)) will be recorded. To stop recording, call
endRecording(). At this point the Canvas that was returned must no longer
be referenced, and nothing should be drawn into it.
int ni = nativeBeginRecording(mNativePicture, width, height);
mRecordingCanvas = new RecordingCanvas(this, ni);
return mRecordingCanvas;
|
public static android.graphics.Picture | createFromStream(java.io.InputStream stream)Create a new picture (already recorded) from the data in the stream. This
data was generated by a previous call to writeToStream().
return new Picture(
nativeCreateFromStream(stream, new byte[WORKING_STREAM_STORAGE]));
|
public void | draw(Canvas canvas)Draw this picture on the canvas. The picture may have the side effect
of changing the matrix and clip of the canvas.
if (mRecordingCanvas != null) {
endRecording();
}
nativeDraw(canvas.mNativeCanvas, mNativePicture);
|
public void | endRecording()Call endRecording when the picture is built. After this call, the picture
may be drawn, but the canvas that was returned by beginRecording must not
be referenced anymore. This is automatically called if Picture.draw() or
Canvas.drawPicture() is called.
if (mRecordingCanvas != null) {
mRecordingCanvas = null;
nativeEndRecording(mNativePicture);
}
|
protected void | finalize()
nativeDestructor(mNativePicture);
|
public native int | getHeight()Get the height of the picture as passed to beginRecording. This
does not reflect (per se) the content of the picture.
|
public native int | getWidth()Get the width of the picture as passed to beginRecording. This
does not reflect (per se) the content of the picture.
|
private static native int | nativeBeginRecording(int nativeCanvas, int w, int h)
|
private static native int | nativeConstructor(int nativeSrcOr0)
|
private static native int | nativeCreateFromStream(java.io.InputStream stream, byte[] storage)
|
private static native void | nativeDestructor(int nativePicture)
|
private static native void | nativeDraw(int nativeCanvas, int nativePicture)
|
private static native void | nativeEndRecording(int nativeCanvas)
|
private static native boolean | nativeWriteToStream(int nativePicture, java.io.OutputStream stream, byte[] storage)
|
final int | ni()
return mNativePicture;
|
public void | writeToStream(java.io.OutputStream stream)Write the picture contents to a stream. The data can be used to recreate
the picture in this or another process by calling createFromStream.
// do explicit check before calling the native method
if (stream == null) {
throw new NullPointerException();
}
if (!nativeWriteToStream(mNativePicture, stream,
new byte[WORKING_STREAM_STORAGE])) {
throw new RuntimeException();
}
|