BitmapFactory.Options.InScreenDensity Property

Definition

The pixel density of the actual screen that is being used.

[Android.Runtime.Register("inScreenDensity")]
public int InScreenDensity { get; set; }
[<Android.Runtime.Register("inScreenDensity")>]
member this.InScreenDensity : int with get, set

Property Value

Attributes

Remarks

The pixel density of the actual screen that is being used. This is purely for applications running in density compatibility code, where #inTargetDensity is actually the density the application sees rather than the real screen density.

By setting this, you allow the loading code to avoid scaling a bitmap that is currently in the screen density up/down to the compatibility density. Instead, if #inDensity is the same as #inScreenDensity, the bitmap will be left as-is. Anything using the resulting bitmap must also used Bitmap#getScaledWidth(int) Bitmap.getScaledWidth and Bitmap#getScaledHeight Bitmap.getScaledHeight to account for any different between the bitmap's density and the target's density.

This is never set automatically for the caller by BitmapFactory itself. It must be explicitly set, since the caller must deal with the resulting bitmap in a density-aware way.

Java documentation for android.graphics.BitmapFactory.Options.inScreenDensity.

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

See also