Bitmap.SetPremultiplied(Boolean) Method

Definition

Sets whether the bitmap should treat its data as pre-multiplied.

[Android.Runtime.Register("setPremultiplied", "(Z)V", "")]
public void SetPremultiplied (bool premultiplied);
[<Android.Runtime.Register("setPremultiplied", "(Z)V", "")>]
member this.SetPremultiplied : bool -> unit

Parameters

premultiplied
Boolean
Attributes

Remarks

Sets whether the bitmap should treat its data as pre-multiplied.

Bitmaps are always treated as pre-multiplied by the view system and Canvas for performance reasons. Storing un-pre-multiplied data in a Bitmap (through #setPixel, #setPixels, or BitmapFactory.Options#inPremultiplied BitmapFactory.Options.inPremultiplied) can lead to incorrect blending if drawn by the framework.

This method will not affect the behavior of a bitmap without an alpha channel, or if #hasAlpha() returns false.

Calling #createBitmap or #createScaledBitmap with a source Bitmap whose colors are not pre-multiplied may result in a RuntimeException, since those functions require drawing the source, which is not supported for un-pre-multiplied Bitmaps.

Java documentation for android.graphics.Bitmap.setPremultiplied(boolean).

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