public static class BitmapFactory.Options extends Object
Modifier and Type | Field and Description |
---|---|
Bitmap |
inBitmap
If set, decode methods that take the Options object will attempt to
reuse this bitmap when loading content.
|
int |
inDensity
The pixel density to use for the bitmap.
|
boolean |
inDither
If dither is true, the decoder will attempt to dither the decoded
image.
|
boolean |
inInputShareable
This field works in conjuction with inPurgeable.
|
boolean |
inJustDecodeBounds
If set to true, the decoder will return null (no bitmap), but
the out...
|
boolean |
inMutable
If set, decode methods will always return a mutable Bitmap instead of
an immutable one.
|
boolean |
inPreferQualityOverSpeed
If inPreferQualityOverSpeed is set to true, the decoder will try to
decode the reconstructed image to a higher quality even at the
expense of the decoding speed.
|
Bitmap.Config |
inPreferredConfig
If this is non-null, the decoder will try to decode into this
internal configuration.
|
boolean |
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.
|
int |
inSampleSize
If set to a value > 1, requests the decoder to subsample the original
image, returning a smaller image to save memory.
|
boolean |
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. |
int |
inScreenDensity
The pixel density of the actual screen that is being used.
|
int |
inTargetDensity
The pixel density of the destination this bitmap will be drawn to.
|
byte[] |
inTempStorage
Temp storage to use for decoding.
|
boolean |
mCancel
Flag to indicate that cancel has been called on this object.
|
int |
outHeight
The resulting height of the bitmap, set independent of the state of
inJustDecodeBounds.
|
String |
outMimeType
If known, this string is set to the mimetype of the decoded image.
|
int |
outWidth
The resulting width of the bitmap, set independent of the state of
inJustDecodeBounds.
|
Constructor and Description |
---|
BitmapFactory.Options()
Create a default Options object, which if left unchanged will give
the same result from the decoder as if null were passed.
|
Modifier and Type | Method and Description |
---|---|
void |
requestCancelDecode()
This can be called from another thread while this options object is
inside a decode...
|
public Bitmap inBitmap
null
and
will throw an IllegalArgumentException. The
current implementation necessitates that the reused bitmap be of the
same size as the source content and in jpeg or png format (whether as a
resource or as a stream). The configuration
of the reused bitmap will override the setting of
inPreferredConfig
, if set.
You should still always use the returned Bitmap of the decode method and not assume that reusing the bitmap worked, due to the constraints outlined above and failure situations that can occur. Checking whether the return value matches the value of the inBitmap set in the Options structure is a way to see if the bitmap was reused, but in all cases you should use the returned Bitmap to make sure that you are using the bitmap that was used as the decode destination.
public boolean inMutable
public boolean inJustDecodeBounds
public int inSampleSize
public Bitmap.Config inPreferredConfig
Bitmap.Config.ARGB_8888
config by
default.public boolean inDither
public int inDensity
Bitmap.setDensity(int)
). In addition,
if 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,
BitmapFactory.decodeResource(Resources, int)
,
BitmapFactory.decodeResource(Resources, int, android.graphics.BitmapFactory.Options)
,
and BitmapFactory.decodeResourceStream(android.content.res.Resources, android.util.TypedValue, java.io.InputStream, android.graphics.Rect, android.graphics.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.
public int inTargetDensity
inDensity
and
inScaled
to determine if and how to scale the bitmap before
returning it.
If this is 0,
BitmapFactory.decodeResource(Resources, int)
,
BitmapFactory.decodeResource(Resources, int, android.graphics.BitmapFactory.Options)
,
and BitmapFactory.decodeResourceStream(android.content.res.Resources, android.util.TypedValue, java.io.InputStream, android.graphics.Rect, android.graphics.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.
inDensity
,
inScreenDensity
,
inScaled
,
DisplayMetrics.densityDpi
public int inScreenDensity
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.
inDensity
,
inTargetDensity
,
inScaled
,
DisplayMetrics.densityDpi
public boolean inScaled
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.
public boolean inPurgeable
public boolean inInputShareable
public boolean inPreferQualityOverSpeed
public int outWidth
public int outHeight
public String outMimeType
public byte[] inTempStorage
public boolean mCancel
public BitmapFactory.Options()
public void requestCancelDecode()