Loading core/jni/android/graphics/BitmapFactory.cpp +4 −1 Original line number Diff line number Diff line Loading @@ -225,6 +225,9 @@ static jobject doDecode(JNIEnv* env, SkStream* stream, jobject padding, if (javaBitmap == NULL) { bitmap = new SkBitmap; } else { if (sampleSize != 1) { return nullObjectReturn("SkImageDecoder: Cannot reuse bitmap with sampleSize != 1"); } bitmap = (SkBitmap *) env->GetIntField(javaBitmap, gBitmap_nativeBitmapFieldID); // config of supplied bitmap overrules config set in options prefConfig = bitmap->getConfig(); Loading @@ -232,7 +235,7 @@ static jobject doDecode(JNIEnv* env, SkStream* stream, jobject padding, Res_png_9patch dummy9Patch; SkAutoTDelete<SkImageDecoder> add(decoder); SkAutoTDelete<SkBitmap> adb(bitmap); SkAutoTDelete<SkBitmap> adb(bitmap, (javaBitmap == NULL)); decoder->setPeeker(&peeker); if (!isPurgeable) { Loading graphics/java/android/graphics/BitmapFactory.java +19 −4 Original line number Diff line number Diff line Loading @@ -44,10 +44,11 @@ public class BitmapFactory { /** * If set, decode methods that take the Options object will attempt to * reuse this bitmap when loading content. This is a hint to the decoder * only, and the decoder may choose to create a new Bitmap instead. The * reuse this bitmap when loading content. If the decode operation cannot * use this bitmap, the decode method will return <code>null</code> 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 format (whether as a * same size as the source content and in jpeg or png format (whether as a * resource or as a stream). The {@link android.graphics.Bitmap.Config * configuration} of the reused bitmap will override the setting of * {@link #inPreferredConfig}, if set. Loading Loading @@ -389,6 +390,10 @@ public class BitmapFactory { } } if (bm == null && opts != null && opts.inBitmap != null) { throw new IllegalArgumentException("Problem decoding into existing bitmap"); } return bm; } Loading Loading @@ -421,7 +426,11 @@ public class BitmapFactory { if ((offset | length) < 0 || data.length < offset + length) { throw new ArrayIndexOutOfBoundsException(); } return nativeDecodeByteArray(data, offset, length, opts); Bitmap bm = nativeDecodeByteArray(data, offset, length, opts); if (bm == null && opts != null && opts.inBitmap != null) { throw new IllegalArgumentException("Problem decoding into existing bitmap"); } return bm; } /** Loading Loading @@ -488,6 +497,9 @@ public class BitmapFactory { if (tempStorage == null) tempStorage = new byte[16 * 1024]; bm = nativeDecodeStream(is, tempStorage, outPadding, opts); } if (bm == null && opts != null && opts.inBitmap != null) { throw new IllegalArgumentException("Problem decoding into existing bitmap"); } return finishDecode(bm, outPadding, opts); } Loading Loading @@ -558,6 +570,9 @@ public class BitmapFactory { */ public static Bitmap decodeFileDescriptor(FileDescriptor fd, Rect outPadding, Options opts) { Bitmap bm = nativeDecodeFileDescriptor(fd, outPadding, opts); if (bm == null && opts != null && opts.inBitmap != null) { throw new IllegalArgumentException("Problem decoding into existing bitmap"); } return finishDecode(bm, outPadding, opts); } Loading Loading
core/jni/android/graphics/BitmapFactory.cpp +4 −1 Original line number Diff line number Diff line Loading @@ -225,6 +225,9 @@ static jobject doDecode(JNIEnv* env, SkStream* stream, jobject padding, if (javaBitmap == NULL) { bitmap = new SkBitmap; } else { if (sampleSize != 1) { return nullObjectReturn("SkImageDecoder: Cannot reuse bitmap with sampleSize != 1"); } bitmap = (SkBitmap *) env->GetIntField(javaBitmap, gBitmap_nativeBitmapFieldID); // config of supplied bitmap overrules config set in options prefConfig = bitmap->getConfig(); Loading @@ -232,7 +235,7 @@ static jobject doDecode(JNIEnv* env, SkStream* stream, jobject padding, Res_png_9patch dummy9Patch; SkAutoTDelete<SkImageDecoder> add(decoder); SkAutoTDelete<SkBitmap> adb(bitmap); SkAutoTDelete<SkBitmap> adb(bitmap, (javaBitmap == NULL)); decoder->setPeeker(&peeker); if (!isPurgeable) { Loading
graphics/java/android/graphics/BitmapFactory.java +19 −4 Original line number Diff line number Diff line Loading @@ -44,10 +44,11 @@ public class BitmapFactory { /** * If set, decode methods that take the Options object will attempt to * reuse this bitmap when loading content. This is a hint to the decoder * only, and the decoder may choose to create a new Bitmap instead. The * reuse this bitmap when loading content. If the decode operation cannot * use this bitmap, the decode method will return <code>null</code> 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 format (whether as a * same size as the source content and in jpeg or png format (whether as a * resource or as a stream). The {@link android.graphics.Bitmap.Config * configuration} of the reused bitmap will override the setting of * {@link #inPreferredConfig}, if set. Loading Loading @@ -389,6 +390,10 @@ public class BitmapFactory { } } if (bm == null && opts != null && opts.inBitmap != null) { throw new IllegalArgumentException("Problem decoding into existing bitmap"); } return bm; } Loading Loading @@ -421,7 +426,11 @@ public class BitmapFactory { if ((offset | length) < 0 || data.length < offset + length) { throw new ArrayIndexOutOfBoundsException(); } return nativeDecodeByteArray(data, offset, length, opts); Bitmap bm = nativeDecodeByteArray(data, offset, length, opts); if (bm == null && opts != null && opts.inBitmap != null) { throw new IllegalArgumentException("Problem decoding into existing bitmap"); } return bm; } /** Loading Loading @@ -488,6 +497,9 @@ public class BitmapFactory { if (tempStorage == null) tempStorage = new byte[16 * 1024]; bm = nativeDecodeStream(is, tempStorage, outPadding, opts); } if (bm == null && opts != null && opts.inBitmap != null) { throw new IllegalArgumentException("Problem decoding into existing bitmap"); } return finishDecode(bm, outPadding, opts); } Loading Loading @@ -558,6 +570,9 @@ public class BitmapFactory { */ public static Bitmap decodeFileDescriptor(FileDescriptor fd, Rect outPadding, Options opts) { Bitmap bm = nativeDecodeFileDescriptor(fd, outPadding, opts); if (bm == null && opts != null && opts.inBitmap != null) { throw new IllegalArgumentException("Problem decoding into existing bitmap"); } return finishDecode(bm, outPadding, opts); } Loading