Android Guides | Samples

Android.Graphics.Bitmap.Premultiplied Property

Indicates whether pixels stored in this bitmaps are stored pre-multiplied.


[get: Android.Runtime.Register("isPremultiplied", "()Z", "GetIsPremultipliedHandler")]
[set: Android.Runtime.Register("setPremultiplied", "(Z)V", "GetSetPremultiplied_ZHandler")]
public Boolean Premultiplied { get; set; }

See Also


Get method documentation[Android Documentation]

Indicates whether pixels stored in this bitmaps are stored pre-multiplied. When a pixel is pre-multiplied, the RGB components have been multiplied by the alpha component. For instance, if the original color is a 50% translucent red (128, 255, 0, 0), the pre-multiplied form is (128, 128, 0, 0).

This method always returns false if Bitmap.GetConfig is NoType:android/graphics/Bitmap$Config;Href=../../../reference/android/graphics/Bitmap.Config.html#RGB_565.

The return value is undefined if Bitmap.GetConfig is NoType:android/graphics/Bitmap$Config;Href=../../../reference/android/graphics/Bitmap.Config.html#ALPHA_8.

This method only returns true if Bitmap.HasAlpha returns true. A bitmap with no alpha channel can be used both as a pre-multiplied and as a non pre-multiplied bitmap.

Only pre-multiplied bitmaps may be drawn by the view system or Canvas. If a non-pre-multiplied bitmap with an alpha channel is drawn to a Canvas, a RuntimeException will be thrown.

Set method documentation[Android Documentation]
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 Bitmap.SetPixel(Int32,Int32,Int32), Bitmap.SetPixels(Int32[],Int32,Int32,Int32,Int32,Int32,Int32), or NoType:android/graphics/BitmapFactory$Options;Href=../../../reference/android/graphics/BitmapFactory.Options.html#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 Bitmap.HasAlpha returns false.

Calling Bitmap.CreateBitmap(Bitmap) or Bitmap.CreateScaledBitmap(Bitmap,Int32,Int32,Int32) 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.


Namespace: Android.Graphics
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions: