From 713e1bb9df6bdfc21bd5c40d1a6ecf6c822a4be5 Mon Sep 17 00:00:00 2001 From: Romain Guy Date: Tue, 16 Oct 2012 18:44:09 -0700 Subject: Add API to enable mipmaps on Bitmap Bug #7353771 This API can be used when scaling large images down to a small size to get nicer looking results. Change-Id: If09087eed36077eee5355f6047a3ca67747d7d9e --- graphics/java/android/graphics/Bitmap.java | 49 +++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) (limited to 'graphics') diff --git a/graphics/java/android/graphics/Bitmap.java b/graphics/java/android/graphics/Bitmap.java index 6238edb..22ecc61 100644 --- a/graphics/java/android/graphics/Bitmap.java +++ b/graphics/java/android/graphics/Bitmap.java @@ -1030,6 +1030,51 @@ public final class Bitmap implements Parcelable { } /** + * Indicates whether the renderer responsible for drawing this + * bitmap should attempt to use mipmaps when this bitmap is drawn + * scaled down. + * + * If you know that you are going to draw this bitmap at less than + * 50% of its original size, you may be able to obtain a higher + * quality + * + * This property is only a suggestion that can be ignored by the + * renderer. It is not guaranteed to have any effect. + * + * @return true if the renderer should attempt to use mipmaps, + * false otherwise + * + * @see #setHasMipMap(boolean) + */ + public final boolean hasMipMap() { + return nativeHasMipMap(mNativeBitmap); + } + + /** + * Set a hint for the renderer responsible for drawing this bitmap + * indicating that it should attempt to use mipmaps when this bitmap + * is drawn scaled down. + * + * If you know that you are going to draw this bitmap at less than + * 50% of its original size, you may be able to obtain a higher + * quality by turning this property on. + * + * Note that if the renderer respects this hint it might have to + * allocate extra memory to hold the mipmap levels for this bitmap. + * + * This property is only a suggestion that can be ignored by the + * renderer. It is not guaranteed to have any effect. + * + * @param hasMipMap indicates whether the renderer should attempt + * to use mipmaps + * + * @see #hasMipMap() + */ + public final void setHasMipMap(boolean hasMipMap) { + nativeSetHasMipMap(mNativeBitmap, hasMipMap); + } + + /** * Fills the bitmap's pixels with the specified {@link Color}. * * @throws IllegalStateException if the bitmap is not mutable. @@ -1356,7 +1401,6 @@ public final class Bitmap implements Parcelable { private static native int nativeHeight(int nativeBitmap); private static native int nativeRowBytes(int nativeBitmap); private static native int nativeConfig(int nativeBitmap); - private static native boolean nativeHasAlpha(int nativeBitmap); private static native int nativeGetPixel(int nativeBitmap, int x, int y); private static native void nativeGetPixels(int nativeBitmap, int[] pixels, @@ -1385,7 +1429,10 @@ public final class Bitmap implements Parcelable { int[] offsetXY); private static native void nativePrepareToDraw(int nativeBitmap); + private static native boolean nativeHasAlpha(int nativeBitmap); private static native void nativeSetHasAlpha(int nBitmap, boolean hasAlpha); + private static native boolean nativeHasMipMap(int nativeBitmap); + private static native void nativeSetHasMipMap(int nBitmap, boolean hasMipMap); private static native boolean nativeSameAs(int nb0, int nb1); /* package */ final int ni() { -- cgit v1.1