java.lang.Object | |
↳ | android.graphics.BitmapFactory.Options |
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
inDensity | The pixel density to use for the bitmap. | ||||||||||
inDither | If dither is true, the decoder will atttempt to dither the decoded image. | ||||||||||
inInputShareable | This field works in conjuction with inPurgeable. | ||||||||||
inJustDecodeBounds | If set to true, the decoder will return null (no bitmap), but the out... | ||||||||||
inPreferredConfig | If this is non-null, the decoder will try to decode into this internal configuration. | ||||||||||
inPurgeable | If this is set to true, then the resulting bitmap will allocate its pixels such that they can be purged if the system needs to reclaim memory. | ||||||||||
inSampleSize | If set to a value > 1, requests the decoder to subsample the original image, returning a smaller image to save memory. | ||||||||||
inScaled | When this flag is set, if inDensity and inTargetDensity are not 0, the bitmap will be scaled to match inTargetDensity when loaded, rather than relying on the graphics system scaling it each time it is drawn to a Canvas. | ||||||||||
inScreenDensity | The pixel density of the actual screen that is being used. | ||||||||||
inTargetDensity | The pixel density of the destination this bitmap will be drawn to. | ||||||||||
inTempStorage | Temp storage to use for decoding. | ||||||||||
mCancel | Flag to indicate that cancel has been called on this object. | ||||||||||
outHeight | The resulting height of the bitmap, set independent of the state of inJustDecodeBounds. | ||||||||||
outMimeType | If known, this string is set to the mimetype of the decoded image. | ||||||||||
outWidth | The resulting width of the bitmap, set independent of the state of inJustDecodeBounds. |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Create a default Options object, which if left unchanged will give
the same result from the decoder as if null were passed.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
This can be called from another thread while this options object is
inside a decode...
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class java.lang.Object
|
The pixel density to use for the bitmap. This will always result in the returned bitmap having a density set for it (see Bitmap.setDensity(int)). In addition, if {@link #inScaled is set (which it is by default} and this density does not match inTargetDensity, then the bitmap will be scaled to the target density before being returned.
If this is 0, decodeResource(Resources, int), decodeResource(Resources, int, android.graphics.BitmapFactory.Options), and decodeResourceStream(Resources, TypedValue, InputStream, Rect, BitmapFactory.Options) will fill in the density associated with the resource. The other functions will leave it as-is and no density will be applied.
If dither is true, the decoder will atttempt to dither the decoded image.
This field works in conjuction with inPurgeable. If inPurgeable is false, then this field is ignored. If inPurgeable is true, then this field determines whether the bitmap can share a reference to the input data (inputstream, array, etc.) or if it must make a deep copy.
If set to true, the decoder will return null (no bitmap), but the out... fields will still be set, allowing the caller to query the bitmap without having to allocate the memory for its pixels.
If this is non-null, the decoder will try to decode into this internal configuration. If it is null, or the request cannot be met, the decoder will try to pick the best matching config based on the system's screen depth, and characteristics of the original image such as if it has per-pixel alpha (requiring a config that also does).
If this is set to true, then the resulting bitmap will allocate its pixels such that they can be purged if the system needs to reclaim memory. In that instance, when the pixels need to be accessed again (e.g. the bitmap is drawn, getPixels() is called), they will be automatically re-decoded. For the re-decode to happen, the bitmap must have access to the encoded data, either by sharing a reference to the input or by making a copy of it. This distinction is controlled by inInputShareable. If this is true, then the bitmap may keep a shallow reference to the input. If this is false, then the bitmap will explicitly make a copy of the input data, and keep that. Even if sharing is allowed, the implementation may still decide to make a deep copy of the input data.
If set to a value > 1, requests the decoder to subsample the original image, returning a smaller image to save memory. The sample size is the number of pixels in either dimension that correspond to a single pixel in the decoded bitmap. For example, inSampleSize == 4 returns an image that is 1/4 the width/height of the original, and 1/16 the number of pixels. Any value <= 1 is treated the same as 1. Note: the decoder will try to fulfill this request, but the resulting bitmap may have different dimensions that precisely what has been requested. Also, powers of 2 are often faster/easier for the decoder to honor.
When this flag is set, if inDensity and inTargetDensity are not 0, the bitmap will be scaled to match inTargetDensity when loaded, rather than relying on the graphics system scaling it each time it is drawn to a Canvas.
This flag is turned on by default and should be turned off if you need a non-scaled version of the bitmap. Nine-patch bitmaps ignore this flag and are always scaled.
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 and 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.
The pixel density of the destination this bitmap will be drawn to. This is used in conjunction with inDensity and inScaled to determine if and how to scale the bitmap before returning it.
If this is 0, decodeResource(Resources, int), decodeResource(Resources, int, android.graphics.BitmapFactory.Options), and decodeResourceStream(Resources, TypedValue, InputStream, Rect, BitmapFactory.Options) will fill in the density associated the Resources object's DisplayMetrics. The other functions will leave it as-is and no scaling for density will be performed.
Flag to indicate that cancel has been called on this object. This is useful if there's an intermediary that wants to first decode the bounds and then decode the image. In that case the intermediary can check, inbetween the bounds decode and the image decode, to see if the operation is canceled.
The resulting height of the bitmap, set independent of the state of inJustDecodeBounds. However, if there is an error trying to decode, outHeight will be set to -1.
If known, this string is set to the mimetype of the decoded image. If not know, or there is an error, it is set to null.
The resulting width of the bitmap, set independent of the state of inJustDecodeBounds. However, if there is an error trying to decode, outWidth will be set to -1.
Create a default Options object, which if left unchanged will give the same result from the decoder as if null were passed.
This can be called from another thread while this options object is inside a decode... call. Calling this will notify the decoder that it should cancel its operation. This is not guaranteed to cancel the decode, but if it does, the decoder... operation will return null, or if inJustDecodeBounds is true, will set outWidth/outHeight to -1