diff options
Diffstat (limited to 'src/com/android/gallery3d/filtershow/filters')
17 files changed, 61 insertions, 37 deletions
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilter.java b/src/com/android/gallery3d/filtershow/filters/ImageFilter.java index c039fce47..662e8ed2b 100644 --- a/src/com/android/gallery3d/filtershow/filters/ImageFilter.java +++ b/src/com/android/gallery3d/filtershow/filters/ImageFilter.java @@ -2,7 +2,6 @@ package com.android.gallery3d.filtershow.filters; import android.graphics.Bitmap; -import android.util.Log; public class ImageFilter implements Cloneable { @@ -26,8 +25,9 @@ public class ImageFilter implements Cloneable { return mName; } - public void apply(Bitmap bitmap) { + public Bitmap apply(Bitmap bitmap, float scaleFactor, boolean highQuality) { // do nothing here, subclasses will implement filtering here + return bitmap; } public int getParameter() { diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterBW.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterBW.java index bc3dd0938..bdbd1d535 100644 --- a/src/com/android/gallery3d/filtershow/filters/ImageFilterBW.java +++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterBW.java @@ -11,10 +11,12 @@ public class ImageFilterBW extends ImageFilter { native protected void nativeApplyFilter(Bitmap bitmap, int w, int h); - public void apply(Bitmap bitmap) { + @Override + public Bitmap apply(Bitmap bitmap, float scaleFactor, boolean highQuality) { int w = bitmap.getWidth(); int h = bitmap.getHeight(); nativeApplyFilter(bitmap, w, h); + return bitmap; } } diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterBWBlue.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterBWBlue.java index 7368be587..b3c8a9ec0 100644 --- a/src/com/android/gallery3d/filtershow/filters/ImageFilterBWBlue.java +++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterBWBlue.java @@ -11,10 +11,12 @@ public class ImageFilterBWBlue extends ImageFilter { native protected void nativeApplyFilter(Bitmap bitmap, int w, int h); - public void apply(Bitmap bitmap) { + @Override + public Bitmap apply(Bitmap bitmap, float scaleFactor, boolean highQuality) { int w = bitmap.getWidth(); int h = bitmap.getHeight(); nativeApplyFilter(bitmap, w, h); + return bitmap; } } diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterBWGreen.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterBWGreen.java index f4e6c61fc..e3963dcf8 100644 --- a/src/com/android/gallery3d/filtershow/filters/ImageFilterBWGreen.java +++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterBWGreen.java @@ -11,10 +11,12 @@ public class ImageFilterBWGreen extends ImageFilter { native protected void nativeApplyFilter(Bitmap bitmap, int w, int h); - public void apply(Bitmap bitmap) { + @Override + public Bitmap apply(Bitmap bitmap, float scaleFactor, boolean highQuality) { int w = bitmap.getWidth(); int h = bitmap.getHeight(); nativeApplyFilter(bitmap, w, h); + return bitmap; } } diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterBWRed.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterBWRed.java index bb7d661ad..19b3c6b3a 100644 --- a/src/com/android/gallery3d/filtershow/filters/ImageFilterBWRed.java +++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterBWRed.java @@ -11,10 +11,12 @@ public class ImageFilterBWRed extends ImageFilter { native protected void nativeApplyFilter(Bitmap bitmap, int w, int h); - public void apply(Bitmap bitmap) { + @Override + public Bitmap apply(Bitmap bitmap, float scaleFactor, boolean highQuality) { int w = bitmap.getWidth(); int h = bitmap.getHeight(); nativeApplyFilter(bitmap, w, h); + return bitmap; } } diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterBorder.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterBorder.java index 7df7a2b6f..67904c600 100644 --- a/src/com/android/gallery3d/filtershow/filters/ImageFilterBorder.java +++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterBorder.java @@ -1,13 +1,10 @@ package com.android.gallery3d.filtershow.filters; -import com.android.gallery3d.R; - import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Rect; import android.graphics.drawable.Drawable; -import android.graphics.drawable.NinePatchDrawable; public class ImageFilterBorder extends ImageFilter { Drawable mNinePatch = null; @@ -24,6 +21,7 @@ public class ImageFilterBorder extends ImageFilter { mNinePatch = ninePatch; } + @Override public boolean same(ImageFilter filter) { boolean isBorderFilter = super.same(filter); if (!isBorderFilter) { @@ -41,9 +39,10 @@ public class ImageFilterBorder extends ImageFilter { mNinePatch = ninePatch; } - public void apply(Bitmap bitmap) { + @Override + public Bitmap apply(Bitmap bitmap, float scaleFactor, boolean highQuality) { if (mNinePatch == null) { - return; + return bitmap; } int w = bitmap.getWidth(); @@ -53,5 +52,6 @@ public class ImageFilterBorder extends ImageFilter { Canvas canvas = new Canvas(bitmap); mNinePatch.setBounds(bounds); mNinePatch.draw(canvas); + return bitmap; } } diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterContrast.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterContrast.java index b3ef74d21..5117f60bc 100644 --- a/src/com/android/gallery3d/filtershow/filters/ImageFilterContrast.java +++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterContrast.java @@ -11,11 +11,13 @@ public class ImageFilterContrast extends ImageFilter { native protected void nativeApplyFilter(Bitmap bitmap, int w, int h, float strength); - public void apply(Bitmap bitmap) { + @Override + public Bitmap apply(Bitmap bitmap, float scaleFactor, boolean highQuality) { int w = bitmap.getWidth(); int h = bitmap.getHeight(); float p = mParameter; float value = p; nativeApplyFilter(bitmap, w, h, value); + return bitmap; } } diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterCurves.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterCurves.java index 5de8ff483..01b280b6e 100644 --- a/src/com/android/gallery3d/filtershow/filters/ImageFilterCurves.java +++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterCurves.java @@ -1,16 +1,15 @@ package com.android.gallery3d.filtershow.filters; -import com.android.gallery3d.filtershow.ui.Spline; - import android.graphics.Bitmap; -import android.util.Log; + +import com.android.gallery3d.filtershow.ui.Spline; public class ImageFilterCurves extends ImageFilter { private static final String LOGTAG = "ImageFilterCurves"; - private float[] mCurve = new float[256]; + private final float[] mCurve = new float[256]; private boolean mUseRed = true; private boolean mUseGreen = true; @@ -49,6 +48,7 @@ public class ImageFilterCurves extends ImageFilter { } } + @Override public boolean same(ImageFilter filter) { boolean isCurveFilter = super.same(filter); if (!isCurveFilter) { @@ -69,8 +69,8 @@ public class ImageFilterCurves extends ImageFilter { } } - public void apply(Bitmap bitmap) { - + @Override + public Bitmap apply(Bitmap bitmap, float scaleFactor, boolean highQuality) { int[] redGradient = null; if (mUseRed) { redGradient = new int[256]; @@ -89,6 +89,7 @@ public class ImageFilterCurves extends ImageFilter { nativeApplyGradientFilter(bitmap, bitmap.getWidth(), bitmap.getHeight(), redGradient, greenGradient, blueGradient); + return bitmap; } public void setSpline(Spline spline) { diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterExposure.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterExposure.java index 85b6e4f6b..ee8741399 100644 --- a/src/com/android/gallery3d/filtershow/filters/ImageFilterExposure.java +++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterExposure.java @@ -12,11 +12,12 @@ public class ImageFilterExposure extends ImageFilter { native protected void nativeApplyFilter(Bitmap bitmap, int w, int h, float bright); @Override - public void apply(Bitmap bitmap) { + public Bitmap apply(Bitmap bitmap, float scaleFactor, boolean highQuality) { int w = bitmap.getWidth(); int h = bitmap.getHeight(); int p = mParameter; float value = p; nativeApplyFilter(bitmap, w, h, value); + return bitmap; } } diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterGradient.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterGradient.java index d27dd34b6..4fbd08613 100644 --- a/src/com/android/gallery3d/filtershow/filters/ImageFilterGradient.java +++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterGradient.java @@ -10,8 +10,6 @@ import android.graphics.Paint; import android.graphics.Paint.Style; import android.graphics.Shader.TileMode; -import com.android.gallery3d.filtershow.ui.Spline; - public class ImageFilterGradient extends ImageFilter { private Bitmap mGradientBitmap = null; @@ -50,8 +48,8 @@ public class ImageFilterGradient extends ImageFilter { mPositions = positions; } - public void apply(Bitmap bitmap) { - + @Override + public Bitmap apply(Bitmap bitmap, float scaleFactor, boolean highQuality) { createGradient(); int[] gradient = new int[256]; int[] redGradient = new int[256]; @@ -66,6 +64,7 @@ public class ImageFilterGradient extends ImageFilter { } nativeApplyGradientFilter(bitmap, bitmap.getWidth(), bitmap.getHeight(), redGradient, greenGradient, blueGradient); + return bitmap; } public void createGradient() { diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterHue.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterHue.java index 874e7ec1e..6f6f9e875 100644 --- a/src/com/android/gallery3d/filtershow/filters/ImageFilterHue.java +++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterHue.java @@ -20,7 +20,8 @@ public class ImageFilterHue extends ImageFilter { native protected void nativeApplyFilter(Bitmap bitmap, int w, int h, float []matrix); - public void apply(Bitmap bitmap) { + @Override + public Bitmap apply(Bitmap bitmap, float scaleFactor, boolean highQuality) { int w = bitmap.getWidth(); int h = bitmap.getHeight(); float p = mParameter; @@ -29,5 +30,7 @@ public class ImageFilterHue extends ImageFilter { cmatrix.setHue(value); nativeApplyFilter(bitmap, w, h, cmatrix.getMatrix()); + + return bitmap; } } diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterRS.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterRS.java index ab2d304a4..ab92e4e5c 100644 --- a/src/com/android/gallery3d/filtershow/filters/ImageFilterRS.java +++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterRS.java @@ -31,9 +31,10 @@ public class ImageFilterRS extends ImageFilter { mOutPixelsAllocation.copyTo(bitmap); } - public void apply(Bitmap bitmap) { + @Override + public Bitmap apply(Bitmap bitmap, float scaleFactor, boolean highQuality) { if (bitmap == null) { - return; + return bitmap; } try { prepare(bitmap); @@ -45,6 +46,7 @@ public class ImageFilterRS extends ImageFilter { } catch (android.renderscript.RSRuntimeException e) { Log.e(LOGTAG, "RS runtime exception ? " + e); } + return bitmap; } public static RenderScript getRenderScriptContext() { diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterSaturated.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterSaturated.java index d3db4419b..904705636 100644 --- a/src/com/android/gallery3d/filtershow/filters/ImageFilterSaturated.java +++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterSaturated.java @@ -11,11 +11,13 @@ public class ImageFilterSaturated extends ImageFilter { native protected void nativeApplyFilter(Bitmap bitmap, int w, int h, float saturation); - public void apply(Bitmap bitmap) { + @Override + public Bitmap apply(Bitmap bitmap, float scaleFactor, boolean highQuality) { int w = bitmap.getWidth(); int h = bitmap.getHeight(); int p = mParameter; float value = 1 + p / 100.0f; nativeApplyFilter(bitmap, w, h, value); + return bitmap; } } diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterShadows.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterShadows.java index 39c95064b..9b379a1ff 100644 --- a/src/com/android/gallery3d/filtershow/filters/ImageFilterShadows.java +++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterShadows.java @@ -11,8 +11,8 @@ public class ImageFilterShadows extends ImageFilter { private final float MID = .5f; private final float HIGHLIGHT = .9f; - private float []baseX = {0f,SHADOW,MID,HIGHLIGHT,1f}; - private float []baseY = {0f,SHADOW,MID,HIGHLIGHT,1f}; + private final float []baseX = {0f,SHADOW,MID,HIGHLIGHT,1f}; + private final float []baseY = {0f,SHADOW,MID,HIGHLIGHT,1f}; public ImageFilterShadows() { mName = "Shadows"; @@ -50,12 +50,14 @@ public class ImageFilterShadows extends ImageFilter { native protected void nativeApplyFilter(Bitmap bitmap, int w, int h, short []valMap); - public void apply(Bitmap bitmap) { + @Override + public Bitmap apply(Bitmap bitmap, float scaleFactor, boolean highQuality) { int w = bitmap.getWidth(); int h = bitmap.getHeight(); float p = mParameter; baseY[1] = (float)(SHADOW*Math.pow(4, mParameter/100.)); nativeApplyFilter(bitmap, w, h, calcMap()); + return bitmap; } } diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterStraighten.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterStraighten.java index 483d901e6..db85292be 100644 --- a/src/com/android/gallery3d/filtershow/filters/ImageFilterStraighten.java +++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterStraighten.java @@ -1,16 +1,13 @@ package com.android.gallery3d.filtershow.filters; -import java.nio.ByteBuffer; - import android.graphics.Bitmap; -import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.Rect; public class ImageFilterStraighten extends ImageFilter { - private Bitmap.Config mConfig = Bitmap.Config.ARGB_8888; + private final Bitmap.Config mConfig = Bitmap.Config.ARGB_8888; private float mRotation; private float mZoomFactor; @@ -39,7 +36,8 @@ public class ImageFilterStraighten extends ImageFilter { mZoomFactor = zoomFactor; } - public void apply(Bitmap bitmap) { + @Override + public Bitmap apply(Bitmap bitmap, float scaleFactor, boolean highQuality) { // TODO: implement bilinear or bicubic here... for now, just use // canvas to do a simple implementation... // TODO: and be more memory efficient! (do it in native?) @@ -64,6 +62,7 @@ public class ImageFilterStraighten extends ImageFilter { temp.recycle(); temp = null; pixels = null; + return bitmap; } } diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterVibrance.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterVibrance.java index fd437ee8a..8281573e6 100644 --- a/src/com/android/gallery3d/filtershow/filters/ImageFilterVibrance.java +++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterVibrance.java @@ -12,11 +12,13 @@ public class ImageFilterVibrance extends ImageFilter { native protected void nativeApplyFilter(Bitmap bitmap, int w, int h, float bright); @Override - public void apply(Bitmap bitmap) { + public Bitmap apply(Bitmap bitmap, float scaleFactor, boolean highQuality) { int w = bitmap.getWidth(); int h = bitmap.getHeight(); int p = mParameter; float value = p; nativeApplyFilter(bitmap, w, h, value); + + return bitmap; } } diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterVignette.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterVignette.java index 24699a2a2..4c43410e3 100644 --- a/src/com/android/gallery3d/filtershow/filters/ImageFilterVignette.java +++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterVignette.java @@ -11,11 +11,14 @@ public class ImageFilterVignette extends ImageFilter { native protected void nativeApplyFilter(Bitmap bitmap, int w, int h, float strength); - public void apply(Bitmap bitmap) { + @Override + public Bitmap apply(Bitmap bitmap, float scaleFactor, boolean highQuality) { int w = bitmap.getWidth(); int h = bitmap.getHeight(); float p = mParameter; float value = p / 100.0f; nativeApplyFilter(bitmap, w, h, value); + + return bitmap; } } |