Unhide inPurgeable in BitmapFactory.Options.

The correctness and effectiveness of the usage of the parameter are evaluated in:
https://android-git.corp.google.com/g/Gerrit#change,2768
This commit is contained in:
Wei-Ta Chen
2009-06-01 15:49:32 -07:00
parent 30b70cec05
commit eb949674fd
2 changed files with 31 additions and 23 deletions

View File

@@ -48699,6 +48699,16 @@
visibility="public" visibility="public"
> >
</field> </field>
<field name="inPurgeable"
type="boolean"
transient="false"
volatile="false"
static="false"
final="false"
deprecated="not deprecated"
visibility="public"
>
</field>
<field name="inSampleSize" <field name="inSampleSize"
type="int" type="int"
transient="false" transient="false"

View File

@@ -18,18 +18,18 @@ package android.graphics;
import android.content.res.AssetManager; import android.content.res.AssetManager;
import android.content.res.Resources; import android.content.res.Resources;
import android.util.TypedValue;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
import android.util.TypedValue;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.IOException;
import java.io.FileDescriptor; import java.io.FileDescriptor;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
/** /**
* Creates Bitmap objects from various sources, including files, streams, * Creates Bitmap objects from various sources, including files, streams,
* and byte-arrays. * and byte-arrays.
*/ */
public class BitmapFactory { public class BitmapFactory {
public static class Options { public static class Options {
@@ -62,7 +62,7 @@ public class BitmapFactory {
* Also, powers of 2 are often faster/easier for the decoder to honor. * Also, powers of 2 are often faster/easier for the decoder to honor.
*/ */
public int inSampleSize; public int inSampleSize;
/** /**
* If this is non-null, the decoder will try to decode into this * 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, * internal configuration. If it is null, or the request cannot be met,
@@ -71,7 +71,7 @@ public class BitmapFactory {
* as if it has per-pixel alpha (requiring a config that also does). * as if it has per-pixel alpha (requiring a config that also does).
*/ */
public Bitmap.Config inPreferredConfig; public Bitmap.Config inPreferredConfig;
/** /**
* If dither is true, the decoder will atttempt to dither the decoded * If dither is true, the decoder will atttempt to dither the decoded
* image. * image.
@@ -117,8 +117,6 @@ public class BitmapFactory {
* explicitly make a copy of the input data, and keep that. Even if * explicitly make a copy of the input data, and keep that. Even if
* sharing is allowed, the implementation may still decide to make a * sharing is allowed, the implementation may still decide to make a
* deep copy of the input data. * deep copy of the input data.
*
* @hide pending API council approval
*/ */
public boolean inPurgeable; public boolean inPurgeable;
@@ -151,12 +149,12 @@ public class BitmapFactory {
* If not know, or there is an error, it is set to null. * If not know, or there is an error, it is set to null.
*/ */
public String outMimeType; public String outMimeType;
/** /**
* Temp storage to use for decoding. Suggest 16K or so. * Temp storage to use for decoding. Suggest 16K or so.
*/ */
public byte[] inTempStorage; public byte[] inTempStorage;
private native void requestCancel(); private native void requestCancel();
/** /**
@@ -167,7 +165,7 @@ public class BitmapFactory {
* if the operation is canceled. * if the operation is canceled.
*/ */
public boolean mCancel; public boolean mCancel;
/** /**
* This can be called from another thread while this options object is * This can be called from another thread while this options object is
* inside a decode... call. Calling this will notify the decoder that * inside a decode... call. Calling this will notify the decoder that
@@ -249,7 +247,7 @@ public class BitmapFactory {
if (opts.inDensity == 0) { if (opts.inDensity == 0) {
opts.inDensity = density == TypedValue.DENSITY_DEFAULT ? opts.inDensity = density == TypedValue.DENSITY_DEFAULT ?
DisplayMetrics.DEFAULT_DENSITY : density; DisplayMetrics.DEFAULT_DENSITY : density;
} }
float scale = opts.inDensity / (float) DisplayMetrics.DEFAULT_DENSITY; float scale = opts.inDensity / (float) DisplayMetrics.DEFAULT_DENSITY;
if (opts.inScaled || isNinePatch) { if (opts.inScaled || isNinePatch) {
@@ -291,7 +289,7 @@ public class BitmapFactory {
*/ */
public static Bitmap decodeResource(Resources res, int id, Options opts) { public static Bitmap decodeResource(Resources res, int id, Options opts) {
Bitmap bm = null; Bitmap bm = null;
try { try {
final TypedValue value = new TypedValue(); final TypedValue value = new TypedValue();
final InputStream is = res.openRawResource(id, value); final InputStream is = res.openRawResource(id, value);
@@ -306,7 +304,7 @@ public class BitmapFactory {
} }
return bm; return bm;
} }
/** /**
* Decode an image referenced by a resource ID. * Decode an image referenced by a resource ID.
* *
@@ -337,7 +335,7 @@ public class BitmapFactory {
} }
return nativeDecodeByteArray(data, offset, length, opts); return nativeDecodeByteArray(data, offset, length, opts);
} }
/** /**
* Decode an immutable bitmap from the specified byte array. * Decode an immutable bitmap from the specified byte array.
* *
@@ -350,13 +348,13 @@ public class BitmapFactory {
public static Bitmap decodeByteArray(byte[] data, int offset, int length) { public static Bitmap decodeByteArray(byte[] data, int offset, int length) {
return decodeByteArray(data, offset, length, null); return decodeByteArray(data, offset, length, null);
} }
/** /**
* Decode an input stream into a bitmap. If the input stream is null, or * Decode an input stream into a bitmap. If the input stream is null, or
* cannot be used to decode a bitmap, the function returns null. * cannot be used to decode a bitmap, the function returns null.
* The stream's position will be where ever it was after the encoded data * The stream's position will be where ever it was after the encoded data
* was read. * was read.
* *
* @param is The input stream that holds the raw data to be decoded into a * @param is The input stream that holds the raw data to be decoded into a
* bitmap. * bitmap.
* @param outPadding If not null, return the padding rect for the bitmap if * @param outPadding If not null, return the padding rect for the bitmap if
@@ -375,7 +373,7 @@ public class BitmapFactory {
if (is == null) { if (is == null) {
return null; return null;
} }
// we need mark/reset to work properly // we need mark/reset to work properly
if (!is.markSupported()) { if (!is.markSupported()) {
@@ -413,7 +411,7 @@ public class BitmapFactory {
* cannot be used to decode a bitmap, the function returns null. * cannot be used to decode a bitmap, the function returns null.
* The stream's position will be where ever it was after the encoded data * The stream's position will be where ever it was after the encoded data
* was read. * was read.
* *
* @param is The input stream that holds the raw data to be decoded into a * @param is The input stream that holds the raw data to be decoded into a
* bitmap. * bitmap.
* @return The decoded bitmap, or null if the image data could not be * @return The decoded bitmap, or null if the image data could not be
@@ -441,7 +439,7 @@ public class BitmapFactory {
public static Bitmap decodeFileDescriptor(FileDescriptor fd, Rect outPadding, Options opts) { public static Bitmap decodeFileDescriptor(FileDescriptor fd, Rect outPadding, Options opts) {
return nativeDecodeFileDescriptor(fd, outPadding, opts); return nativeDecodeFileDescriptor(fd, outPadding, opts);
} }
/** /**
* Decode a bitmap from the file descriptor. If the bitmap cannot be decoded * Decode a bitmap from the file descriptor. If the bitmap cannot be decoded
* return null. The position within the descriptor will not be changed when * return null. The position within the descriptor will not be changed when
@@ -453,7 +451,7 @@ public class BitmapFactory {
public static Bitmap decodeFileDescriptor(FileDescriptor fd) { public static Bitmap decodeFileDescriptor(FileDescriptor fd) {
return nativeDecodeFileDescriptor(fd, null, null); return nativeDecodeFileDescriptor(fd, null, null);
} }
private static native Bitmap nativeDecodeStream(InputStream is, byte[] storage, private static native Bitmap nativeDecodeStream(InputStream is, byte[] storage,
Rect padding, Options opts); Rect padding, Options opts);
private static native Bitmap nativeDecodeFileDescriptor(FileDescriptor fd, private static native Bitmap nativeDecodeFileDescriptor(FileDescriptor fd,