Compartilhar via


Bitmap.PrepareToDraw Method

Definition

Builds caches associated with the bitmap that are used for drawing it.

[Android.Runtime.Register("prepareToDraw", "()V", "")]
public void PrepareToDraw ();
[<Android.Runtime.Register("prepareToDraw", "()V", "")>]
member this.PrepareToDraw : unit -> unit
Attributes

Remarks

Builds caches associated with the bitmap that are used for drawing it.

Starting in android.os.Build.VERSION_CODES#N, this call initiates an asynchronous upload to the GPU on RenderThread, if the Bitmap is not already uploaded. With Hardware Acceleration, Bitmaps must be uploaded to the GPU in order to be rendered. This is done by default the first time a Bitmap is drawn, but the process can take several milliseconds, depending on the size of the Bitmap. Each time a Bitmap is modified and drawn again, it must be re-uploaded.

Calling this method in advance can save time in the first frame it's used. For example, it is recommended to call this on an image decoding worker thread when a decoded Bitmap is about to be displayed. It is recommended to make any pre-draw modifications to the Bitmap before calling this method, so the cached, uploaded copy may be reused without re-uploading.

In android.os.Build.VERSION_CODES#KITKAT and below, for purgeable bitmaps, this call would attempt to ensure that the pixels have been decoded.

Java documentation for android.graphics.Bitmap.prepareToDraw().

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.

Applies to