summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/com/android/gallery3d/app/CommonControllerOverlay.java4
-rw-r--r--src/com/android/gallery3d/filtershow/FilterShowActivity.java68
-rw-r--r--src/com/android/gallery3d/filtershow/ImageStateAdapter.java8
-rw-r--r--src/com/android/gallery3d/filtershow/PanelController.java113
-rw-r--r--src/com/android/gallery3d/filtershow/cache/FilteringPipeline.java58
-rw-r--r--src/com/android/gallery3d/filtershow/cache/ImageLoader.java8
-rw-r--r--src/com/android/gallery3d/filtershow/cache/RenderingRequest.java3
-rw-r--r--src/com/android/gallery3d/filtershow/editors/EditorDraw.java13
-rw-r--r--src/com/android/gallery3d/filtershow/editors/EditorRedEye.java61
-rw-r--r--src/com/android/gallery3d/filtershow/editors/EditorTinyPlanet.java1
-rw-r--r--src/com/android/gallery3d/filtershow/filters/BaseFiltersManager.java113
-rw-r--r--src/com/android/gallery3d/filtershow/filters/FilterBasicRepresentation.java4
-rw-r--r--src/com/android/gallery3d/filtershow/filters/FilterDrawRepresentation.java31
-rw-r--r--src/com/android/gallery3d/filtershow/filters/FilterFxRepresentation.java2
-rw-r--r--src/com/android/gallery3d/filtershow/filters/FilterRedEyeRepresentation.java103
-rw-r--r--src/com/android/gallery3d/filtershow/filters/FilterRepresentation.java15
-rw-r--r--src/com/android/gallery3d/filtershow/filters/FilterTinyPlanetRepresentation.java2
-rw-r--r--src/com/android/gallery3d/filtershow/filters/ImageFilter.java6
-rw-r--r--src/com/android/gallery3d/filtershow/filters/ImageFilterBorder.java6
-rw-r--r--src/com/android/gallery3d/filtershow/filters/ImageFilterBwFilter.java2
-rw-r--r--src/com/android/gallery3d/filtershow/filters/ImageFilterContrast.java2
-rw-r--r--src/com/android/gallery3d/filtershow/filters/ImageFilterCurves.java2
-rw-r--r--src/com/android/gallery3d/filtershow/filters/ImageFilterDownsample.java4
-rw-r--r--src/com/android/gallery3d/filtershow/filters/ImageFilterDraw.java84
-rw-r--r--src/com/android/gallery3d/filtershow/filters/ImageFilterEdge.java2
-rw-r--r--src/com/android/gallery3d/filtershow/filters/ImageFilterExposure.java2
-rw-r--r--src/com/android/gallery3d/filtershow/filters/ImageFilterFx.java2
-rw-r--r--src/com/android/gallery3d/filtershow/filters/ImageFilterGeometry.java2
-rw-r--r--src/com/android/gallery3d/filtershow/filters/ImageFilterHue.java2
-rw-r--r--src/com/android/gallery3d/filtershow/filters/ImageFilterKMeans.java2
-rw-r--r--src/com/android/gallery3d/filtershow/filters/ImageFilterNegative.java2
-rw-r--r--src/com/android/gallery3d/filtershow/filters/ImageFilterParametricBorder.java4
-rw-r--r--src/com/android/gallery3d/filtershow/filters/ImageFilterRS.java14
-rw-r--r--src/com/android/gallery3d/filtershow/filters/ImageFilterRedEye.java144
-rw-r--r--src/com/android/gallery3d/filtershow/filters/ImageFilterSaturated.java2
-rw-r--r--src/com/android/gallery3d/filtershow/filters/ImageFilterShadows.java2
-rw-r--r--src/com/android/gallery3d/filtershow/filters/ImageFilterSharpen.java2
-rw-r--r--src/com/android/gallery3d/filtershow/filters/ImageFilterStraighten.java2
-rw-r--r--src/com/android/gallery3d/filtershow/filters/ImageFilterTinyPlanet.java2
-rw-r--r--src/com/android/gallery3d/filtershow/filters/ImageFilterVibrance.java2
-rw-r--r--src/com/android/gallery3d/filtershow/filters/ImageFilterVignette.java2
-rw-r--r--src/com/android/gallery3d/filtershow/filters/ImageFilterWBalance.java4
-rw-r--r--src/com/android/gallery3d/filtershow/filters/SimpleImageFilter.java4
-rw-r--r--src/com/android/gallery3d/filtershow/imageshow/GeometryListener.java21
-rw-r--r--src/com/android/gallery3d/filtershow/imageshow/GeometryMetadata.java4
-rw-r--r--src/com/android/gallery3d/filtershow/imageshow/ImageDraw.java4
-rw-r--r--src/com/android/gallery3d/filtershow/imageshow/ImageRedEye.java (renamed from src/com/android/gallery3d/filtershow/imageshow/ImageRedEyes.java)76
-rw-r--r--src/com/android/gallery3d/filtershow/imageshow/ImageShow.java8
-rw-r--r--src/com/android/gallery3d/filtershow/imageshow/MasterImage.java23
-rw-r--r--src/com/android/gallery3d/filtershow/presets/ImagePreset.java22
-rw-r--r--src/com/android/gallery3d/filtershow/tools/SaveCopyTask.java2
-rw-r--r--src/com/android/gallery3d/filtershow/ui/FilterIconButton.java68
-rw-r--r--src/com/android/gallery3d/filtershow/ui/IconButton.java2
-rw-r--r--src/com/android/gallery3d/filtershow/ui/ImageCurves.java2
-rw-r--r--src_pd/com/android/gallery3d/filtershow/filters/FiltersManager.java87
55 files changed, 820 insertions, 410 deletions
diff --git a/src/com/android/gallery3d/app/CommonControllerOverlay.java b/src/com/android/gallery3d/app/CommonControllerOverlay.java
index 089872fa5..a5aa805ef 100644
--- a/src/com/android/gallery3d/app/CommonControllerOverlay.java
+++ b/src/com/android/gallery3d/app/CommonControllerOverlay.java
@@ -274,10 +274,6 @@ public abstract class CommonControllerOverlay extends FrameLayout implements
mBackground.layout(0, y - mTimeBar.getBarHeight(), w, y);
mTimeBar.layout(pl, y - mTimeBar.getPreferredHeight(), w - pr, y);
- // Needed, otherwise the framework will not re-layout in case only the
- // padding is changed
- mTimeBar.requestLayout();
-
// Put the play/pause/next/ previous button in the center of the screen
layoutCenteredView(mPlayPauseReplayView, 0, 0, w, h);
diff --git a/src/com/android/gallery3d/filtershow/FilterShowActivity.java b/src/com/android/gallery3d/filtershow/FilterShowActivity.java
index f061842cd..e2d35801a 100644
--- a/src/com/android/gallery3d/filtershow/FilterShowActivity.java
+++ b/src/com/android/gallery3d/filtershow/FilterShowActivity.java
@@ -16,7 +16,6 @@
package com.android.gallery3d.filtershow;
-import android.annotation.TargetApi;
import android.app.ActionBar;
import android.app.Activity;
import android.app.ProgressDialog;
@@ -30,7 +29,6 @@ import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.graphics.Point;
-import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.AsyncTask;
@@ -57,13 +55,14 @@ import com.android.gallery3d.filtershow.cache.ImageLoader;
import com.android.gallery3d.filtershow.editors.BasicEditor;
import com.android.gallery3d.filtershow.editors.EditorDraw;
import com.android.gallery3d.filtershow.editors.EditorManager;
+import com.android.gallery3d.filtershow.editors.EditorRedEye;
import com.android.gallery3d.filtershow.editors.ImageOnlyEditor;
import com.android.gallery3d.filtershow.editors.EditorTinyPlanet;
import com.android.gallery3d.filtershow.filters.*;
import com.android.gallery3d.filtershow.imageshow.ImageCrop;
import com.android.gallery3d.filtershow.imageshow.ImageDraw;
import com.android.gallery3d.filtershow.imageshow.ImageFlip;
-import com.android.gallery3d.filtershow.imageshow.ImageRedEyes;
+import com.android.gallery3d.filtershow.imageshow.ImageRedEye;
import com.android.gallery3d.filtershow.imageshow.ImageRotate;
import com.android.gallery3d.filtershow.imageshow.ImageShow;
import com.android.gallery3d.filtershow.imageshow.ImageStraighten;
@@ -83,7 +82,6 @@ import java.io.IOException;
import java.lang.ref.WeakReference;
import java.util.Vector;
-@TargetApi(16)
public class FilterShowActivity extends Activity implements OnItemClickListener,
OnShareTargetSelectedListener {
@@ -98,7 +96,7 @@ public class FilterShowActivity extends Activity implements OnItemClickListener,
private final PanelController mPanelController = new PanelController();
private ImageLoader mImageLoader = null;
private ImageShow mImageShow = null;
- private ImageRedEyes mImageRedEyes = null;
+ private ImageRedEye mImageRedEye = null;
private ImageDraw mImageDraw = null;
private ImageStraighten mImageStraighten = null;
private ImageCrop mImageCrop = null;
@@ -201,7 +199,7 @@ public class FilterShowActivity extends Activity implements OnItemClickListener,
mImageRotate = (ImageRotate) findViewById(R.id.imageRotate);
mImageFlip = (ImageFlip) findViewById(R.id.imageFlip);
mImageTinyPlanet = (ImageTinyPlanet) findViewById(R.id.imageTinyPlanet);
- mImageRedEyes = (ImageRedEyes) findViewById(R.id.imageRedEyes);
+ mImageRedEye = (ImageRedEye) findViewById(R.id.imageRedEyes);
mImageDraw = (ImageDraw) findViewById(R.id.imageDraw);
mImageCrop.setAspectTextSize((int) getPixelsFromDip(18));
@@ -213,13 +211,14 @@ public class FilterShowActivity extends Activity implements OnItemClickListener,
mImageViews.add(mImageRotate);
mImageViews.add(mImageFlip);
mImageViews.add(mImageTinyPlanet);
- mImageViews.add(mImageRedEyes);
+ mImageViews.add(mImageRedEye);
mEditorPlaceHolder.setContainer((FrameLayout) findViewById(R.id.editorContainer));
mEditorPlaceHolder.addEditor(new EditorDraw());
mEditorPlaceHolder.addEditor(new BasicEditor());
mEditorPlaceHolder.addEditor(new ImageOnlyEditor());
mEditorPlaceHolder.addEditor(new EditorTinyPlanet());
+ mEditorPlaceHolder.addEditor(new EditorRedEye());
EditorManager.addEditors(mEditorPlaceHolder);
mEditorPlaceHolder.setOldViews(mImageViews);
mEditorPlaceHolder.setImageLoader(mImageLoader);
@@ -253,7 +252,7 @@ public class FilterShowActivity extends Activity implements OnItemClickListener,
mImageRotate.setImageLoader(mImageLoader);
mImageFlip.setImageLoader(mImageLoader);
mImageTinyPlanet.setImageLoader(mImageLoader);
- mImageRedEyes.setImageLoader(mImageLoader);
+ mImageRedEye.setImageLoader(mImageLoader);
mImageDraw.setImageLoader(mImageLoader);
mPanelController.setActivity(this);
@@ -281,13 +280,14 @@ public class FilterShowActivity extends Activity implements OnItemClickListener,
mPanelController.addPanel(mColorsButton, mListColors, 3);
Vector<FilterRepresentation> filtersRepresentations = new Vector<FilterRepresentation>();
- FiltersManager.addFilterRepresentations(filtersRepresentations);
+
+ FiltersManager filtersManager = FiltersManager.getManager();
+ filtersManager.addEffects(filtersRepresentations);
+
for (FilterRepresentation representation : filtersRepresentations) {
setupFilterRepresentationButton(representation, listColors, mColorsButton);
}
- mPanelController.addFilter(new ImageFilterRedEye());
-
mPanelController.addView(findViewById(R.id.applyEffect));
findViewById(R.id.resetOperationsButton).setOnClickListener(
createOnClickResetOperationsButton());
@@ -464,9 +464,11 @@ public class FilterShowActivity extends Activity implements OnItemClickListener,
loading.setVisibility(View.GONE);
final View filters = findViewById(R.id.filtersPanel);
filters.setVisibility(View.VISIBLE);
- float y = filters.getY();
- filters.setY(y + filters.getHeight());
- filters.animate().setDuration(600).y(y).withLayer().start();
+ if (PanelController.useAnimations()) {
+ float y = filters.getY();
+ filters.setY(y + filters.getHeight());
+ filters.animate().setDuration(600).y(y).withLayer().start();
+ }
final View imageShow = findViewById(R.id.imageShow);
imageShow.setVisibility(View.VISIBLE);
@@ -773,6 +775,12 @@ public class FilterShowActivity extends Activity implements OnItemClickListener,
mNullFxFilter = setupFilterRepresentationButton(nullFx, listFilters, mFxButton);
mNullFxFilter.setSelected(true);
+ Vector<FilterRepresentation> filtersRepresentations = new Vector<FilterRepresentation>();
+ FiltersManager.getManager().addLooks(filtersRepresentations);
+ for (FilterRepresentation representation : filtersRepresentations) {
+ setupFilterRepresentationButton(representation, listFilters, mFxButton);
+ }
+
for (int i = 0; i < p; i++) {
setupFilterRepresentationButton(fxArray[i], listFilters, mFxButton);
}
@@ -859,7 +867,8 @@ public class FilterShowActivity extends Activity implements OnItemClickListener,
int translate = translateMainPanel(viewList);
if (!mShowingImageStatePanel) {
mShowingImageStatePanel = true;
- view.animate().setDuration(200).x(translate)
+ if (PanelController.useAnimations()) {
+ view.animate().setDuration(200).x(translate)
.withLayer().withEndAction(new Runnable() {
@Override
public void run() {
@@ -869,11 +878,22 @@ public class FilterShowActivity extends Activity implements OnItemClickListener,
.alpha(1.0f).start();
}
}).start();
+ } else {
+ view.setX(translate);
+ viewList.setAlpha(0);
+ viewList.setVisibility(View.VISIBLE);
+ viewList.animate().setDuration(100)
+ .alpha(1.0f).start();
+ }
} else {
mShowingImageStatePanel = false;
viewList.setVisibility(View.INVISIBLE);
- view.animate().setDuration(200).x(0).withLayer()
+ if (PanelController.useAnimations()) {
+ view.animate().setDuration(200).x(0).withLayer()
.start();
+ } else {
+ view.setX(0);
+ }
}
invalidateOptionsMenu();
}
@@ -917,7 +937,8 @@ public class FilterShowActivity extends Activity implements OnItemClickListener,
int translate = translateMainPanel(viewList);
if (!mShowingHistoryPanel) {
mShowingHistoryPanel = true;
- view.animate().setDuration(200).x(translate)
+ if (PanelController.useAnimations()) {
+ view.animate().setDuration(200).x(translate)
.withLayer().withEndAction(new Runnable() {
@Override
public void run() {
@@ -927,11 +948,22 @@ public class FilterShowActivity extends Activity implements OnItemClickListener,
.alpha(1.0f).start();
}
}).start();
+ } else {
+ view.setX(translate);
+ viewList.setAlpha(0);
+ viewList.setVisibility(View.VISIBLE);
+ viewList.animate().setDuration(100)
+ .alpha(1.0f).start();
+ }
} else {
mShowingHistoryPanel = false;
viewList.setVisibility(View.INVISIBLE);
- view.animate().setDuration(200).x(0).withLayer()
+ if (PanelController.useAnimations()) {
+ view.animate().setDuration(200).x(0).withLayer()
.start();
+ } else {
+ view.setX(0);
+ }
}
invalidateOptionsMenu();
}
diff --git a/src/com/android/gallery3d/filtershow/ImageStateAdapter.java b/src/com/android/gallery3d/filtershow/ImageStateAdapter.java
index 5de96961c..58e0035bc 100644
--- a/src/com/android/gallery3d/filtershow/ImageStateAdapter.java
+++ b/src/com/android/gallery3d/filtershow/ImageStateAdapter.java
@@ -24,9 +24,10 @@ import android.widget.ArrayAdapter;
import android.widget.TextView;
import com.android.gallery3d.R;
+import com.android.gallery3d.filtershow.filters.FilterRepresentation;
import com.android.gallery3d.filtershow.filters.ImageFilter;
-public class ImageStateAdapter extends ArrayAdapter<ImageFilter> {
+public class ImageStateAdapter extends ArrayAdapter<FilterRepresentation> {
private static final String LOGTAG = "ImageStateAdapter";
public ImageStateAdapter(Context context, int textViewResourceId) {
@@ -41,13 +42,12 @@ public class ImageStateAdapter extends ArrayAdapter<ImageFilter> {
Context.LAYOUT_INFLATER_SERVICE);
view = inflater.inflate(R.layout.filtershow_imagestate_row, null);
}
- ImageFilter filter = getItem(position);
+ FilterRepresentation filter = getItem(position);
if (filter != null) {
TextView itemLabel = (TextView) view.findViewById(R.id.imagestate_label);
itemLabel.setText(filter.getName());
TextView itemParameter = (TextView) view.findViewById(R.id.imagestate_parameter);
- // TODO: fix the image state adapter
- // itemParameter.setText("" + filter.getParameter());
+ itemParameter.setText(filter.getStateRepresentation());
}
return view;
}
diff --git a/src/com/android/gallery3d/filtershow/PanelController.java b/src/com/android/gallery3d/filtershow/PanelController.java
index ce7216289..561ac6c81 100644
--- a/src/com/android/gallery3d/filtershow/PanelController.java
+++ b/src/com/android/gallery3d/filtershow/PanelController.java
@@ -16,6 +16,7 @@
package com.android.gallery3d.filtershow;
+import android.annotation.TargetApi;
import android.content.Context;
import android.text.Html;
import android.view.View;
@@ -48,6 +49,14 @@ public class PanelController implements OnClickListener {
private boolean mDisableFilterButtons = false;
private boolean mFixedAspect = false;
+ public static boolean useAnimations() {
+ int currentapiVersion = android.os.Build.VERSION.SDK_INT;
+ if (currentapiVersion >= android.os.Build.VERSION_CODES.JELLY_BEAN) {
+ return true;
+ }
+ return false;
+ }
+
public void setFixedAspect(boolean t) {
mFixedAspect = t;
}
@@ -86,16 +95,28 @@ public class PanelController implements OnClickListener {
} else {
delta = w;
}
- anim.x(delta);
+ if (PanelController.useAnimations()) {
+ anim.x(delta);
+ } else {
+ mContainer.setX(delta);
+ }
} else if (move == VERTICAL_MOVE) {
- anim.y(h);
- }
- anim.setDuration(ANIM_DURATION).withLayer().withEndAction(new Runnable() {
- @Override
- public void run() {
- mContainer.setVisibility(View.GONE);
+ if (PanelController.useAnimations()) {
+ anim.y(h);
+ } else {
+ mContainer.setY(h);
}
- });
+ }
+ if (PanelController.useAnimations()) {
+ anim.setDuration(ANIM_DURATION).withLayer().withEndAction(new Runnable() {
+ @Override
+ public void run() {
+ mContainer.setVisibility(View.GONE);
+ }
+ });
+ } else {
+ mContainer.setVisibility(View.GONE);
+ }
return anim;
}
@@ -107,18 +128,20 @@ public class PanelController implements OnClickListener {
ViewPropertyAnimator anim = mContainer.animate();
int w = mRowPanel.getWidth();
int h = mRowPanel.getHeight();
- if (move == HORIZONTAL_MOVE) {
- if (oldPos < mPosition) {
- mContainer.setX(w);
- } else {
- mContainer.setX(-w);
+ if (useAnimations()) {
+ if (move == HORIZONTAL_MOVE) {
+ if (oldPos < mPosition) {
+ mContainer.setX(w);
+ } else {
+ mContainer.setX(-w);
+ }
+ anim.x(0);
+ } else if (move == VERTICAL_MOVE) {
+ mContainer.setY(h);
+ anim.y(0);
}
- anim.x(0);
- } else if (move == VERTICAL_MOVE) {
- mContainer.setY(h);
- anim.y(0);
+ anim.setDuration(ANIM_DURATION).withLayer();
}
- anim.setDuration(ANIM_DURATION).withLayer();
return anim;
}
}
@@ -186,12 +209,16 @@ public class PanelController implements OnClickListener {
mView.setY(0);
int h = mRowPanel.getHeight();
anim.y(-h);
- anim.setDuration(ANIM_DURATION).withLayer().withEndAction(new Runnable() {
- @Override
- public void run() {
- mView.setVisibility(View.GONE);
- }
- });
+ if (PanelController.useAnimations()) {
+ anim.setDuration(ANIM_DURATION).withLayer().withEndAction(new Runnable() {
+ @Override
+ public void run() {
+ mView.setVisibility(View.GONE);
+ }
+ });
+ } else {
+ mView.setVisibility(View.GONE);
+ }
mSelected = false;
return anim;
}
@@ -202,10 +229,13 @@ public class PanelController implements OnClickListener {
mView.setX(0);
mView.setY(-h);
updateText();
+ mSelected = true;
ViewPropertyAnimator anim = mView.animate();
anim.y(0);
- anim.setDuration(ANIM_DURATION).withLayer();
- mSelected = true;
+ anim.setDuration(ANIM_DURATION);
+ if (PanelController.useAnimations()) {
+ anim.withLayer();
+ }
return anim;
}
@@ -368,10 +398,14 @@ public class PanelController implements OnClickListener {
if (mUtilityPanel != null && mUtilityPanel.selected()) {
ViewPropertyAnimator anim1 = mUtilityPanel.unselect();
removedUtilityPanel = true;
- anim1.start();
+ if (anim1 != null) {
+ anim1.start();
+ }
if (mCurrentPanel == view) {
ViewPropertyAnimator anim2 = current.select(-1, VERTICAL_MOVE);
- anim2.start();
+ if (anim2 != null) {
+ anim2.start();
+ }
showDefaultImageView();
}
}
@@ -387,15 +421,22 @@ public class PanelController implements OnClickListener {
currentPos = current.getPosition();
}
ViewPropertyAnimator anim1 = panel.select(currentPos, HORIZONTAL_MOVE);
- anim1.start();
+ if (anim1 != null) {
+ anim1.start();
+ }
if (current != null) {
ViewPropertyAnimator anim2 = current.unselect(panel.getPosition(), HORIZONTAL_MOVE);
- anim2.start();
+ if (anim2 != null) {
+ anim2.start();
+ }
}
} else {
ViewPropertyAnimator anim = panel.select(-1, VERTICAL_MOVE);
- anim.start();
+ if (anim != null) {
+ anim.start();
+ }
}
+
showDefaultImageView();
mCurrentPanel = view;
}
@@ -481,13 +522,17 @@ public class PanelController implements OnClickListener {
}
}
- if (mUtilityPanel != null && !mUtilityPanel.selected() && doPanelTransition ) {
+ if (mUtilityPanel != null && !mUtilityPanel.selected() && doPanelTransition) {
Panel current = mPanels.get(mCurrentPanel);
ViewPropertyAnimator anim1 = current.unselect(-1, VERTICAL_MOVE);
- anim1.start();
+ if (anim1 != null) {
+ anim1.start();
+ }
if (mUtilityPanel != null) {
ViewPropertyAnimator anim2 = mUtilityPanel.select();
- anim2.start();
+ if (anim2 != null) {
+ anim2.start();
+ }
}
}
diff --git a/src/com/android/gallery3d/filtershow/cache/FilteringPipeline.java b/src/com/android/gallery3d/filtershow/cache/FilteringPipeline.java
index 08a9a718e..419abe85d 100644
--- a/src/com/android/gallery3d/filtershow/cache/FilteringPipeline.java
+++ b/src/com/android/gallery3d/filtershow/cache/FilteringPipeline.java
@@ -22,6 +22,8 @@ import android.os.Process;
import android.support.v8.renderscript.*;
import android.util.Log;
+import com.android.gallery3d.filtershow.filters.BaseFiltersManager;
+import com.android.gallery3d.filtershow.filters.FiltersManager;
import com.android.gallery3d.filtershow.filters.ImageFilterRS;
import com.android.gallery3d.filtershow.imageshow.GeometryMetadata;
import com.android.gallery3d.filtershow.imageshow.MasterImage;
@@ -130,10 +132,16 @@ public class FilteringPipeline implements Handler.Callback {
}
mResizedOriginalBitmap = Bitmap.createScaledBitmap(mOriginalBitmap, w, h, true);
*/
+
GeometryMetadata geometry = preset.getGeometry();
if (mPreviousGeometry != null && geometry.equals(mPreviousGeometry)) {
return false;
}
+
+ if (DEBUG) {
+ Log.v(LOGTAG, "geometry has changed");
+ }
+
RenderScript RS = ImageFilterRS.getRenderScriptContext();
if (mFiltersOnlyOriginalAllocation != null) {
mFiltersOnlyOriginalAllocation.destroy();
@@ -146,7 +154,10 @@ public class FilteringPipeline implements Handler.Callback {
mResizedOriginalBitmap = preset.applyGeometry(mOriginalBitmap);
mOriginalAllocation = Allocation.createFromBitmap(RS, mResizedOriginalBitmap,
Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_SCRIPT);
+
mPreviousGeometry = new GeometryMetadata(geometry);
+
+ FiltersManager.getManager().resetBitmapsRS();
return true;
}
@@ -180,31 +191,67 @@ public class FilteringPipeline implements Handler.Callback {
private void setPresetParameters(ImagePreset preset) {
preset.setScaleFactor(mPreviewScaleFactor);
if (mPreviewScaleFactor < 1.0f) {
- preset.setIsHighQuality(false);
+ preset.setQuality(ImagePreset.QUALITY_PREVIEW);
} else {
- preset.setIsHighQuality(true);
+ preset.setQuality(ImagePreset.QUALITY_PREVIEW);
}
}
+ private String getType(RenderingRequest request) {
+ if (request.getType() == RenderingRequest.ICON_RENDERING) {
+ return "ICON_RENDERING";
+ }
+ if (request.getType() == RenderingRequest.FILTERS_RENDERING) {
+ return "FILTERS_RENDERING";
+ }
+ if (request.getType() == RenderingRequest.FULL_RENDERING) {
+ return "FULL_RENDERING";
+ }
+ if (request.getType() == RenderingRequest.GEOMETRY_RENDERING) {
+ return "GEOMETRY_RENDERING";
+ }
+ return "UNKNOWN TYPE!";
+ }
+
private void render(RenderingRequest request) {
if (request.getBitmap() == null
|| request.getImagePreset() == null) {
return;
}
+ if (DEBUG) {
+ Log.v(LOGTAG, "render image of type " + getType(request));
+ }
+
Bitmap bitmap = request.getBitmap();
ImagePreset preset = request.getImagePreset();
- updateOriginalAllocation(preset);
+ setPresetParameters(preset);
+ if (request.getType() == RenderingRequest.FILTERS_RENDERING) {
+ FiltersManager.getManager().resetBitmapsRS();
+ }
+
+ if (request.getType() != RenderingRequest.ICON_RENDERING) {
+ updateOriginalAllocation(preset);
+ }
+ if (DEBUG) {
+ Log.v(LOGTAG, "after update, req bitmap (" + bitmap.getWidth() + "x" + bitmap.getHeight()
+ +" ? resizeOriginal (" + mResizedOriginalBitmap.getWidth() + "x"
+ + mResizedOriginalBitmap.getHeight());
+ }
if (request.getType() == RenderingRequest.FULL_RENDERING
|| request.getType() == RenderingRequest.GEOMETRY_RENDERING) {
mOriginalAllocation.copyTo(bitmap);
- } else {
+ } else if (request.getType() == RenderingRequest.FILTERS_RENDERING) {
mFiltersOnlyOriginalAllocation.copyTo(bitmap);
}
if (request.getType() == RenderingRequest.FULL_RENDERING
- || request.getType() == RenderingRequest.FILTERS_RENDERING) {
+ || request.getType() == RenderingRequest.FILTERS_RENDERING
+ || request.getType() == RenderingRequest.ICON_RENDERING) {
Bitmap bmp = preset.apply(bitmap);
request.setBitmap(bmp);
}
+ if (request.getType() == RenderingRequest.FILTERS_RENDERING) {
+ FiltersManager.getManager().resetBitmapsRS();
+ }
}
private void compute(TripleBufferBitmap buffer, ImagePreset preset, int type) {
@@ -228,6 +275,7 @@ public class FilteringPipeline implements Handler.Callback {
}
mOriginalAllocation.copyTo(bitmap);
+ setPresetParameters(preset);
bitmap = preset.apply(bitmap);
time = System.currentTimeMillis() - time;
diff --git a/src/com/android/gallery3d/filtershow/cache/ImageLoader.java b/src/com/android/gallery3d/filtershow/cache/ImageLoader.java
index b47d13b9e..00fcf4e19 100644
--- a/src/com/android/gallery3d/filtershow/cache/ImageLoader.java
+++ b/src/com/android/gallery3d/filtershow/cache/ImageLoader.java
@@ -280,7 +280,7 @@ public class ImageLoader {
return null;
}
- static final int MAX_BITMAP_DIM = 2048;
+ static final int MAX_BITMAP_DIM = 900;
private Bitmap loadScaledBitmap(Uri uri, int size) {
InputStream is = null;
@@ -392,7 +392,7 @@ public class ImageLoader {
public void saveImage(ImagePreset preset, final FilterShowActivity filterShowActivity,
File destination) {
- preset.setIsHighQuality(true);
+ preset.setQuality(ImagePreset.QUALITY_FINAL);
preset.setScaleFactor(1.0f);
new SaveCopyTask(mContext, mUri, destination, new SaveCopyTask.Callback() {
@@ -432,7 +432,7 @@ public class ImageLoader {
public void returnFilteredResult(ImagePreset preset,
final FilterShowActivity filterShowActivity) {
- preset.setIsHighQuality(true);
+ preset.setQuality(ImagePreset.QUALITY_FINAL);
preset.setScaleFactor(1.0f);
BitmapTask.Callbacks<ImagePreset> cb = new BitmapTask.Callbacks<ImagePreset>() {
@@ -448,7 +448,7 @@ public class ImageLoader {
@Override
public Bitmap onExecute(ImagePreset param) {
- if (param == null) {
+ if (param == null || mUri == null) {
return null;
}
Bitmap bitmap = loadMutableBitmap(mContext, mUri);
diff --git a/src/com/android/gallery3d/filtershow/cache/RenderingRequest.java b/src/com/android/gallery3d/filtershow/cache/RenderingRequest.java
index c995a9ff3..2815936f8 100644
--- a/src/com/android/gallery3d/filtershow/cache/RenderingRequest.java
+++ b/src/com/android/gallery3d/filtershow/cache/RenderingRequest.java
@@ -30,6 +30,7 @@ public class RenderingRequest {
public static int FULL_RENDERING = 0;
public static int FILTERS_RENDERING = 1;
public static int GEOMETRY_RENDERING = 2;
+ public static int ICON_RENDERING = 3;
private static final Bitmap.Config mConfig = Bitmap.Config.ARGB_8888;
public static void post(Bitmap source, ImagePreset preset, int type,
@@ -40,7 +41,7 @@ public class RenderingRequest {
}
RenderingRequest request = new RenderingRequest();
Bitmap bitmap = null;
- if (type == FULL_RENDERING || type == GEOMETRY_RENDERING) {
+ if (type == FULL_RENDERING || type == GEOMETRY_RENDERING || type == ICON_RENDERING) {
bitmap = preset.applyGeometry(source);
} else {
bitmap = Bitmap.createBitmap(source.getWidth(), source.getHeight(), mConfig);
diff --git a/src/com/android/gallery3d/filtershow/editors/EditorDraw.java b/src/com/android/gallery3d/filtershow/editors/EditorDraw.java
index ff4018501..aa5ec61e8 100644
--- a/src/com/android/gallery3d/filtershow/editors/EditorDraw.java
+++ b/src/com/android/gallery3d/filtershow/editors/EditorDraw.java
@@ -111,14 +111,19 @@ public class EditorDraw extends Editor {
showColorGrid(item);
} else if (item.getItemId() == R.id.draw_menu_size) {
showSizeDialog(item);
- } else if (item.getItemId() == R.id.draw_menu_style_brush) {
+ } else if (item.getItemId() == R.id.draw_menu_style_brush_marker) {
ImageDraw idraw = (ImageDraw) mImageShow;
- idraw.setStyle((byte) (idraw.getStyle() + 1));
- item.setIcon(idraw.getIcon(mContext));
- popupMenu.show();
+ idraw.setStyle(ImageFilterDraw.BRUSH_STYLE_MARKER);
+ } else if (item.getItemId() == R.id.draw_menu_style_brush_spatter) {
+ ImageDraw idraw = (ImageDraw) mImageShow;
+ idraw.setStyle(ImageFilterDraw.BRUSH_STYLE_SPATTER);
} else if (item.getItemId() == R.id.draw_menu_style_line) {
ImageDraw idraw = (ImageDraw) mImageShow;
idraw.setStyle(ImageFilterDraw.SIMPLE_STYLE);
+ } else if (item.getItemId() == R.id.draw_menu_clear) {
+ ImageDraw idraw = (ImageDraw) mImageShow;
+ idraw.resetParameter();
+ commitLocalRepresentation();
}
mView.invalidate();
return true;
diff --git a/src/com/android/gallery3d/filtershow/editors/EditorRedEye.java b/src/com/android/gallery3d/filtershow/editors/EditorRedEye.java
new file mode 100644
index 000000000..271f16535
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/editors/EditorRedEye.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.gallery3d.filtershow.editors;
+
+import android.content.Context;
+import android.util.Log;
+import android.widget.FrameLayout;
+
+import com.android.gallery3d.R;
+import com.android.gallery3d.filtershow.filters.FilterRedEyeRepresentation;
+import com.android.gallery3d.filtershow.filters.FilterRepresentation;
+import com.android.gallery3d.filtershow.imageshow.ImageRedEye;
+
+/**
+ * The editor with no slider for filters without UI
+ */
+public class EditorRedEye extends Editor {
+ public static int ID = R.id.editorRedEye;
+ private final String LOGTAG = "EditorRedEye";
+ ImageRedEye mImageRedEyes;
+
+ public EditorRedEye() {
+ super(ID);
+ }
+
+ protected EditorRedEye(int id) {
+ super(id);
+ }
+
+ @Override
+ public void createEditor(Context context, FrameLayout frameLayout) {
+ super.createEditor(context, frameLayout);
+ mView = mImageShow = mImageRedEyes= new ImageRedEye(context);
+ mImageRedEyes.setEditor(this);
+ }
+
+ @Override
+ public void reflectCurrentFilter() {
+ super.reflectCurrentFilter();
+
+ FilterRepresentation rep = getLocalRepresentation();
+ if (rep != null && getLocalRepresentation() instanceof FilterRedEyeRepresentation) {
+ FilterRedEyeRepresentation redEyeRep = (FilterRedEyeRepresentation) rep;
+ mImageRedEyes.setRepresentation(redEyeRep);
+ }
+ }
+}
diff --git a/src/com/android/gallery3d/filtershow/editors/EditorTinyPlanet.java b/src/com/android/gallery3d/filtershow/editors/EditorTinyPlanet.java
index 4f30dc1d7..d21950912 100644
--- a/src/com/android/gallery3d/filtershow/editors/EditorTinyPlanet.java
+++ b/src/com/android/gallery3d/filtershow/editors/EditorTinyPlanet.java
@@ -48,7 +48,6 @@ public class EditorTinyPlanet extends BasicEditor {
FilterRepresentation rep = getLocalRepresentation();
if (rep != null && getLocalRepresentation() instanceof FilterTinyPlanetRepresentation) {
FilterTinyPlanetRepresentation drawRep = (FilterTinyPlanetRepresentation) rep;
-
mImageTinyPlanet.setRepresentation(drawRep);
}
}
diff --git a/src/com/android/gallery3d/filtershow/filters/BaseFiltersManager.java b/src/com/android/gallery3d/filtershow/filters/BaseFiltersManager.java
new file mode 100644
index 000000000..43660d6a0
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/filters/BaseFiltersManager.java
@@ -0,0 +1,113 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.gallery3d.filtershow.filters;
+
+import com.android.gallery3d.filtershow.cache.ImageLoader;
+
+import java.util.HashMap;
+import java.util.Vector;
+
+public class BaseFiltersManager {
+
+ private static final String LOGTAG = "BaseFiltersManager";
+ private static HashMap<Class, ImageFilter> mFilters = new HashMap<Class, ImageFilter>();
+
+ protected BaseFiltersManager() {
+ Vector<ImageFilter> filters = new Vector<ImageFilter>();
+ addFilters(filters);
+ for (ImageFilter filter : filters) {
+ mFilters.put(filter.getClass(), filter);
+ }
+ }
+
+ protected void addFilters(Vector<ImageFilter> filters) {
+ filters.add(new ImageFilterTinyPlanet());
+ filters.add(new ImageFilterRedEye());
+ filters.add(new ImageFilterWBalance());
+ filters.add(new ImageFilterExposure());
+ filters.add(new ImageFilterVignette());
+ filters.add(new ImageFilterContrast());
+ filters.add(new ImageFilterShadows());
+ filters.add(new ImageFilterVibrance());
+ filters.add(new ImageFilterSharpen());
+ filters.add(new ImageFilterCurves());
+ filters.add(new ImageFilterDraw());
+ filters.add(new ImageFilterHue());
+ filters.add(new ImageFilterSaturated());
+ filters.add(new ImageFilterBwFilter());
+ filters.add(new ImageFilterNegative());
+ filters.add(new ImageFilterEdge());
+ filters.add(new ImageFilterKMeans());
+ filters.add(new ImageFilterFx());
+ filters.add(new ImageFilterBorder());
+ filters.add(new ImageFilterParametricBorder());
+ }
+
+ public ImageFilter getFilter(Class c) {
+ return mFilters.get(c);
+ }
+
+ public ImageFilter getFilterForRepresentation(FilterRepresentation representation) {
+ return mFilters.get(representation.getFilterClass());
+ }
+
+ public void addFilter(Class filterClass, ImageFilter filter) {
+ mFilters.put(filterClass, filter);
+ }
+
+ public FilterRepresentation getRepresentation(Class c) {
+ ImageFilter filter = mFilters.get(c);
+ if (filter != null) {
+ return filter.getDefaultRepresentation();
+ }
+ return null;
+ }
+
+ public void addLooks(Vector<FilterRepresentation> representations) {
+ // subclass can add representations
+ }
+
+ public void addEffects(Vector<FilterRepresentation> representations) {
+ representations.add(getRepresentation(ImageFilterTinyPlanet.class));
+ representations.add(getRepresentation(ImageFilterRedEye.class));
+ representations.add(getRepresentation(ImageFilterWBalance.class));
+ representations.add(getRepresentation(ImageFilterExposure.class));
+ representations.add(getRepresentation(ImageFilterVignette.class));
+ representations.add(getRepresentation(ImageFilterContrast.class));
+ representations.add(getRepresentation(ImageFilterShadows.class));
+ representations.add(getRepresentation(ImageFilterVibrance.class));
+ representations.add(getRepresentation(ImageFilterSharpen.class));
+ representations.add(getRepresentation(ImageFilterCurves.class));
+ representations.add(getRepresentation(ImageFilterDraw.class));
+ representations.add(getRepresentation(ImageFilterHue.class));
+ representations.add(getRepresentation(ImageFilterSaturated.class));
+ representations.add(getRepresentation(ImageFilterBwFilter.class));
+ representations.add(getRepresentation(ImageFilterNegative.class));
+ representations.add(getRepresentation(ImageFilterEdge.class));
+ representations.add(getRepresentation(ImageFilterKMeans.class));
+ }
+
+ public void resetBitmapsRS() {
+ for (Class c : mFilters.keySet()) {
+ ImageFilter filter = mFilters.get(c);
+ if (filter instanceof ImageFilterRS) {
+ ImageFilterRS filterRS = (ImageFilterRS) filter;
+ filterRS.resetBitmap();
+ }
+ }
+ }
+}
diff --git a/src/com/android/gallery3d/filtershow/filters/FilterBasicRepresentation.java b/src/com/android/gallery3d/filtershow/filters/FilterBasicRepresentation.java
index f6f308dba..2410ebe72 100644
--- a/src/com/android/gallery3d/filtershow/filters/FilterBasicRepresentation.java
+++ b/src/com/android/gallery3d/filtershow/filters/FilterBasicRepresentation.java
@@ -121,4 +121,8 @@ public class FilterBasicRepresentation extends FilterRepresentation {
public void setPreviewValue(int previewValue) {
mPreviewValue = previewValue;
}
+
+ public String getStateRepresentation() {
+ return "" + getValue();
+ }
}
diff --git a/src/com/android/gallery3d/filtershow/filters/FilterDrawRepresentation.java b/src/com/android/gallery3d/filtershow/filters/FilterDrawRepresentation.java
index b8fa0a3d4..e41f0a622 100644
--- a/src/com/android/gallery3d/filtershow/filters/FilterDrawRepresentation.java
+++ b/src/com/android/gallery3d/filtershow/filters/FilterDrawRepresentation.java
@@ -17,6 +17,8 @@
package com.android.gallery3d.filtershow.filters;
import android.graphics.Path;
+import android.util.Log;
+
import com.android.gallery3d.R;
import com.android.gallery3d.filtershow.editors.EditorDraw;
@@ -30,7 +32,7 @@ public class FilterDrawRepresentation extends FilterRepresentation {
public Path mPath;
public float mRadius;
public int mColor;
-
+ public int noPoints = 0;
@Override
public String toString() {
return "stroke(" + mType + ", path(" + (mPath) + "), " + mRadius + " , "
@@ -48,7 +50,7 @@ public class FilterDrawRepresentation extends FilterRepresentation {
public FilterDrawRepresentation() {
super("Draw");
setFilterClass(ImageFilterDraw.class);
- setFilterType(FilterRepresentation.TYPE_VIGNETTE);
+ setPriority(FilterRepresentation.TYPE_VIGNETTE);
setTextId(R.string.imageDraw);
setButtonId(R.id.drawOnImageButton);
setEditorId(EditorDraw.ID);
@@ -57,7 +59,8 @@ public class FilterDrawRepresentation extends FilterRepresentation {
@Override
public String toString() {
return getName() + " : strokes=" + mDrawing.size()
- + ((mCurrent == null) ? " no current " : ("current=" + mCurrent.mType));
+ + ((mCurrent == null) ? " no current "
+ : ("draw=" + mCurrent.mType + " " + mCurrent.noPoints));
}
public Vector<StrokeData> getDrawing() {
@@ -91,10 +94,15 @@ public class FilterDrawRepresentation extends FilterRepresentation {
}
if (representation.mDrawing != null) {
mDrawing = (Vector<StrokeData>) representation.mDrawing.clone();
+ } else {
+ mDrawing = null;
}
+
} catch (CloneNotSupportedException e) {
e.printStackTrace();
}
+ } else {
+ Log.v(LOGTAG, "cannot use parameters from " + a);
}
}
@@ -104,8 +112,18 @@ public class FilterDrawRepresentation extends FilterRepresentation {
return false;
}
if (representation instanceof FilterDrawRepresentation) {
- // FIXME!
- return true;
+ FilterDrawRepresentation fdRep = (FilterDrawRepresentation) representation;
+ if (fdRep.mDrawing.size() != mDrawing.size())
+ return false;
+ if (fdRep.mCurrent == null && mCurrent.mPath == null) {
+ return true;
+ }
+ if (fdRep.mCurrent != null && mCurrent.mPath != null) {
+ if (fdRep.mCurrent.noPoints == mCurrent.noPoints) {
+ return true;
+ }
+ return false;
+ }
}
return false;
}
@@ -117,14 +135,17 @@ public class FilterDrawRepresentation extends FilterRepresentation {
mCurrent.mType = type;
mCurrent.mPath = new Path();
mCurrent.mPath.moveTo(x, y);
+ mCurrent.noPoints = 0;
}
public void addPoint(float x, float y) {
+ mCurrent.noPoints++;
mCurrent.mPath.lineTo(x, y);
}
public void endSection(float x, float y) {
mCurrent.mPath.lineTo(x, y);
+ mCurrent.noPoints++;
mDrawing.add(mCurrent);
mCurrent = null;
}
diff --git a/src/com/android/gallery3d/filtershow/filters/FilterFxRepresentation.java b/src/com/android/gallery3d/filtershow/filters/FilterFxRepresentation.java
index fa3fe720b..859bf327c 100644
--- a/src/com/android/gallery3d/filtershow/filters/FilterFxRepresentation.java
+++ b/src/com/android/gallery3d/filtershow/filters/FilterFxRepresentation.java
@@ -31,7 +31,7 @@ public class FilterFxRepresentation extends FilterRepresentation {
mBitmapResource = bitmapResource;
mNameResource = nameResource;
setFilterClass(ImageFilterFx.class);
- setFilterType(FilterRepresentation.TYPE_FX);
+ setPriority(FilterRepresentation.TYPE_FX);
setTextId(nameResource);
setEditorId(ImageOnlyEditor.ID);
setShowEditingControls(false);
diff --git a/src/com/android/gallery3d/filtershow/filters/FilterRedEyeRepresentation.java b/src/com/android/gallery3d/filtershow/filters/FilterRedEyeRepresentation.java
new file mode 100644
index 000000000..2667cc8e9
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/filters/FilterRedEyeRepresentation.java
@@ -0,0 +1,103 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.gallery3d.filtershow.filters;
+
+import android.graphics.RectF;
+import android.util.Log;
+
+import com.android.gallery3d.R;
+import com.android.gallery3d.filtershow.editors.EditorRedEye;
+
+import java.util.Vector;
+
+public class FilterRedEyeRepresentation extends FilterRepresentation {
+ private static final String LOGTAG = "FilterRedEyeRepresentation";
+ private Vector<RedEyeCandidate> mCandidates = new Vector<RedEyeCandidate>();
+
+ public FilterRedEyeRepresentation() {
+ super("RedEye");
+ setFilterClass(ImageFilterRedEye.class);
+ setPriority(FilterRepresentation.TYPE_NORMAL);
+ setButtonId(R.id.redEyeButton);
+ setTextId(R.string.redeye);
+ setEditorId(EditorRedEye.ID);
+ }
+
+ @Override
+ public FilterRepresentation clone() throws CloneNotSupportedException {
+ FilterRedEyeRepresentation representation = (FilterRedEyeRepresentation) super
+ .clone();
+ representation.mCandidates = (Vector<RedEyeCandidate>) mCandidates.clone();
+ return representation;
+ }
+
+ public boolean hasCandidates() {
+ return mCandidates != null;
+ }
+
+ public Vector<RedEyeCandidate> getCandidates() {
+ return mCandidates;
+ }
+
+ public void setCandidates(Vector<RedEyeCandidate> mCandidates) {
+ this.mCandidates = mCandidates;
+ }
+
+ public RedEyeCandidate getCandidate(int index) {
+ return this.mCandidates.get(index);
+ }
+
+ public void addCandidate(RedEyeCandidate c) {
+ this.mCandidates.add(c);
+ }
+
+ public void removeCandidate(RedEyeCandidate c) {
+ this.mCandidates.remove(c);
+ }
+
+ public void clearCandidates() {
+ this.mCandidates.clear();
+ }
+
+ public int getNumberOfCandidates() {
+ if (mCandidates == null) {
+ return 0;
+ }
+ return mCandidates.size();
+ }
+
+ public void addRect(RectF rect, RectF bounds) {
+ if (!hasCandidates()) {
+ setCandidates(new Vector<RedEyeCandidate>());
+ }
+ Vector<RedEyeCandidate> intersects = new Vector<RedEyeCandidate>();
+ for (int i = 0; i < getCandidates().size(); i++) {
+ RedEyeCandidate r = getCandidate(i);
+ if (r.intersect(rect)) {
+ intersects.add(r);
+ }
+ }
+ for (int i = 0; i < intersects.size(); i++) {
+ RedEyeCandidate r = intersects.elementAt(i);
+ rect.union(r.mRect);
+ bounds.union(r.mBounds);
+ removeCandidate(r);
+ }
+ addCandidate(new RedEyeCandidate(rect, bounds));
+ }
+
+}
diff --git a/src/com/android/gallery3d/filtershow/filters/FilterRepresentation.java b/src/com/android/gallery3d/filtershow/filters/FilterRepresentation.java
index f282d2966..0aa449303 100644
--- a/src/com/android/gallery3d/filtershow/filters/FilterRepresentation.java
+++ b/src/com/android/gallery3d/filtershow/filters/FilterRepresentation.java
@@ -23,7 +23,7 @@ import com.android.gallery3d.filtershow.presets.ImagePreset;
public class FilterRepresentation implements Cloneable {
private static final String LOGTAG = "FilterRepresentation";
private String mName;
- private int mPriority;
+ private int mPriority = TYPE_NORMAL;
private ImagePreset mPreset;
private Class mFilterClass;
private int mTextId = 0;
@@ -40,7 +40,6 @@ public class FilterRepresentation implements Cloneable {
public static final byte TYPE_VIGNETTE = 4;
public static final byte TYPE_NORMAL = 5;
public static final byte TYPE_TINYPLANET = 6;
- private byte filterType = TYPE_NORMAL;
public FilterRepresentation(String name) {
mName = name;
@@ -86,14 +85,6 @@ public class FilterRepresentation implements Cloneable {
return mName;
}
- public byte getFilterType() {
- return filterType;
- }
-
- protected void setFilterType(byte type) {
- filterType = type;
- }
-
public void setName(String name) {
mName = name;
}
@@ -195,4 +186,8 @@ public class FilterRepresentation implements Cloneable {
public void setShowUtilityPanel(boolean showUtilityPanel) {
mShowUtilityPanel = showUtilityPanel;
}
+
+ public String getStateRepresentation() {
+ return "";
+ }
}
diff --git a/src/com/android/gallery3d/filtershow/filters/FilterTinyPlanetRepresentation.java b/src/com/android/gallery3d/filtershow/filters/FilterTinyPlanetRepresentation.java
index 9bf2f0bf3..7b69ce9e0 100644
--- a/src/com/android/gallery3d/filtershow/filters/FilterTinyPlanetRepresentation.java
+++ b/src/com/android/gallery3d/filtershow/filters/FilterTinyPlanetRepresentation.java
@@ -27,7 +27,7 @@ public class FilterTinyPlanetRepresentation extends FilterBasicRepresentation {
super("TinyPlanet", 0, 50, 100);
setShowParameterValue(true);
setFilterClass(ImageFilterTinyPlanet.class);
- setFilterType(FilterRepresentation.TYPE_TINYPLANET);
+ setPriority(FilterRepresentation.TYPE_TINYPLANET);
setTextId(R.string.tinyplanet);
setButtonId(R.id.tinyplanetButton);
setEditorId(EditorTinyPlanet.ID);
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilter.java b/src/com/android/gallery3d/filtershow/filters/ImageFilter.java
index d7a76d614..00499cb74 100644
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilter.java
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilter.java
@@ -37,7 +37,7 @@ public class ImageFilter implements Cloneable {
return mName;
}
- public Bitmap apply(Bitmap bitmap, float scaleFactor, boolean highQuality) {
+ public Bitmap apply(Bitmap bitmap, float scaleFactor, int quality) {
// do nothing here, subclasses will implement filtering here
return bitmap;
}
@@ -46,8 +46,8 @@ public class ImageFilter implements Cloneable {
* Called on small bitmaps to create button icons for each filter.
* Override this to provide filter-specific button icons.
*/
- public Bitmap iconApply(Bitmap bitmap, float scaleFactor, boolean highQuality) {
- return apply(bitmap, scaleFactor, highQuality);
+ public Bitmap iconApply(Bitmap bitmap, float scaleFactor, int quality) {
+ return apply(bitmap, scaleFactor, quality);
}
public ImagePreset getImagePreset() {
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterBorder.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterBorder.java
index 0f1e8d600..70e7f2220 100644
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilterBorder.java
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterBorder.java
@@ -63,7 +63,7 @@ public class ImageFilterBorder extends ImageFilter {
}
@Override
- public Bitmap apply(Bitmap bitmap, float scaleFactor, boolean highQuality) {
+ public Bitmap apply(Bitmap bitmap, float scaleFactor, int quality) {
if (getParameters() == null || getParameters().getDrawableResource() == 0) {
return bitmap;
}
@@ -73,7 +73,7 @@ public class ImageFilterBorder extends ImageFilter {
}
@Override
- public Bitmap iconApply(Bitmap bitmap, float scaleFactor, boolean highQuality) {
+ public Bitmap iconApply(Bitmap bitmap, float scaleFactor, int quality) {
if (getParameters() == null || getParameters().getDrawableResource() == 0) {
return bitmap;
}
@@ -91,7 +91,7 @@ public class ImageFilterBorder extends ImageFilter {
public Drawable getDrawable(int rsc) {
Drawable drawable = mDrawables.get(rsc);
- if (drawable == null && mResources != null) {
+ if (drawable == null && mResources != null && rsc != 0) {
drawable = new BitmapDrawable(mResources, BitmapFactory.decodeResource(mResources, rsc));
mDrawables.put(rsc, drawable);
}
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterBwFilter.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterBwFilter.java
index 3580dd693..c92ac012d 100644
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilterBwFilter.java
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterBwFilter.java
@@ -42,7 +42,7 @@ public class ImageFilterBwFilter extends SimpleImageFilter {
native protected void nativeApplyFilter(Bitmap bitmap, int w, int h, int r, int g, int b);
@Override
- public Bitmap apply(Bitmap bitmap, float scaleFactor, boolean highQuality) {
+ public Bitmap apply(Bitmap bitmap, float scaleFactor, int quality) {
if (getParameters() == null) {
return bitmap;
}
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterContrast.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterContrast.java
index e2664269b..36da68b7b 100644
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilterContrast.java
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterContrast.java
@@ -38,7 +38,7 @@ public class ImageFilterContrast extends SimpleImageFilter {
native protected void nativeApplyFilter(Bitmap bitmap, int w, int h, float strength);
@Override
- public Bitmap apply(Bitmap bitmap, float scaleFactor, boolean highQuality) {
+ public Bitmap apply(Bitmap bitmap, float scaleFactor, int quality) {
if (getParameters() == null) {
return bitmap;
}
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterCurves.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterCurves.java
index 4b65a0016..aa4cf22e6 100644
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilterCurves.java
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterCurves.java
@@ -55,7 +55,7 @@ public class ImageFilterCurves extends ImageFilter {
}
@Override
- public Bitmap apply(Bitmap bitmap, float scaleFactor, boolean highQuality) {
+ public Bitmap apply(Bitmap bitmap, float scaleFactor, int quality) {
if (!mParameters.getSpline(Spline.RGB).isOriginal()) {
int[] rgbGradient = new int[256];
populateArray(rgbGradient, Spline.RGB);
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterDownsample.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterDownsample.java
index a53d2f3b3..906467344 100644
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilterDownsample.java
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterDownsample.java
@@ -47,7 +47,7 @@ public class ImageFilterDownsample extends SimpleImageFilter {
}
@Override
- public Bitmap apply(Bitmap bitmap, float scaleFactor, boolean highQuality) {
+ public Bitmap apply(Bitmap bitmap, float scaleFactor, int quality) {
if (getParameters() == null) {
return bitmap;
}
@@ -79,7 +79,7 @@ public class ImageFilterDownsample extends SimpleImageFilter {
}
@Override
- public Bitmap iconApply(Bitmap bitmap, float scaleFactor, boolean highQuality) {
+ public Bitmap iconApply(Bitmap bitmap, float scaleFactor, int quality) {
int w = bitmap.getWidth();
int h = bitmap.getHeight();
Bitmap ret = Bitmap.createScaledBitmap(bitmap, w / ICON_DOWNSAMPLE_FRACTION, h
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterDraw.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterDraw.java
index ed02c1de4..9fa4ce97e 100644
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilterDraw.java
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterDraw.java
@@ -16,7 +16,6 @@
package com.android.gallery3d.filtershow.filters;
-import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
@@ -28,19 +27,20 @@ import android.graphics.Path;
import android.graphics.PathMeasure;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
+import android.util.Log;
import com.android.gallery3d.R;
-import com.android.gallery3d.filtershow.FilterShowActivity;
-import com.android.gallery3d.filtershow.editors.EditorDraw;
import com.android.gallery3d.filtershow.filters.FilterDrawRepresentation.StrokeData;
import com.android.gallery3d.filtershow.imageshow.MasterImage;
+import com.android.gallery3d.filtershow.presets.ImagePreset;
import java.util.Vector;
public class ImageFilterDraw extends ImageFilter {
private static final String LOGTAG = "ImageFilterDraw";
public final static byte SIMPLE_STYLE = 0;
- public final static byte BRUSH_STYLE = 1;
+ public final static byte BRUSH_STYLE_SPATTER = 1;
+ public final static byte BRUSH_STYLE_MARKER = 2;
public final static int NUMBER_OF_STYLES = 3;
Bitmap mOverlayBitmap; // this accelerates interaction
int mCachedStrokes = -1;
@@ -53,7 +53,10 @@ public class ImageFilterDraw extends ImageFilter {
}
DrawStyle[] mDrawingsTypes = new DrawStyle[] {
- new SimpleDraw(), new Brush(R.drawable.brush1), new Brush(R.drawable.brush2) };
+ new SimpleDraw(),
+ new Brush(R.drawable.brush_marker),
+ new Brush(R.drawable.brush_spatter)
+ };
{
for (int i = 0; i < mDrawingsTypes.length; i++) {
mDrawingsTypes[i].setType((byte) i);
@@ -83,7 +86,7 @@ public class ImageFilterDraw extends ImageFilter {
public static interface DrawStyle {
public void setType(byte type);
public void paint(FilterDrawRepresentation.StrokeData sd, Canvas canvas, Matrix toScrMatrix,
- boolean highQuality);
+ int quality);
}
class SimpleDraw implements DrawStyle {
@@ -96,7 +99,7 @@ public class ImageFilterDraw extends ImageFilter {
@Override
public void paint(FilterDrawRepresentation.StrokeData sd, Canvas canvas, Matrix toScrMatrix,
- boolean highQuality) {
+ int quality) {
if (sd == null) {
return;
}
@@ -109,7 +112,7 @@ public class ImageFilterDraw extends ImageFilter {
paint.setColor(sd.mColor);
paint.setStrokeWidth(toScrMatrix.mapRadius(sd.mRadius));
- // don this way because of a bug in path.transform(matrix)
+ // done this way because of a bug in path.transform(matrix)
Path mCacheTransPath = new Path();
mCacheTransPath.addPath(sd.mPath, toScrMatrix);
@@ -118,7 +121,7 @@ public class ImageFilterDraw extends ImageFilter {
}
class Brush implements DrawStyle {
- int mBrushID = R.drawable.brush2;
+ int mBrushID;
Bitmap mBrush;
byte mType;
@@ -137,24 +140,33 @@ public class ImageFilterDraw extends ImageFilter {
@Override
public void paint(FilterDrawRepresentation.StrokeData sd, Canvas canvas, Matrix toScrMatrix,
- boolean highQuality) {
- if (sd == null) {
- return;
- }
-
+ int quality) {
if (sd == null || sd.mPath == null) {
return;
}
Paint paint = new Paint();
paint.setStyle(Style.STROKE);
-
- float scale = toScrMatrix.mapRadius(1);
+ paint.setAntiAlias(true);
Path mCacheTransPath = new Path();
mCacheTransPath.addPath(sd.mPath, toScrMatrix);
- draw(canvas, paint, sd.mColor, toScrMatrix.mapRadius(sd.mRadius),
+ draw(canvas, paint, sd.mColor, toScrMatrix.mapRadius(sd.mRadius) * 2,
mCacheTransPath);
}
+ public Bitmap createScaledBitmap(Bitmap src, int dstWidth, int dstHeight, boolean filter)
+ {
+ Matrix m = new Matrix();
+ m.setScale(dstWidth / (float) src.getWidth(), dstHeight / (float) src.getHeight());
+ Bitmap result = Bitmap.createBitmap(dstWidth, dstHeight, src.getConfig());
+ Canvas canvas = new Canvas(result);
+
+ Paint paint = new Paint();
+ paint.setFilterBitmap(filter);
+ canvas.drawBitmap(src, m, paint);
+
+ return result;
+
+ }
void draw(Canvas canvas, Paint paint, int color, float size, Path path) {
PathMeasure mPathMeasure = new PathMeasure();
float[] mPosition = new float[2];
@@ -164,11 +176,15 @@ public class ImageFilterDraw extends ImageFilter {
paint.setAntiAlias(true);
paint.setColor(color);
+
paint.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.MULTIPLY));
- Bitmap brush = Bitmap.createScaledBitmap(getBrush(), (int) size, (int) size, true);
+ Bitmap brush;
+ // done this way because of a bug in
+ // Bitmap.createScaledBitmap(getBrush(),(int) size,(int) size,true);
+ brush = createScaledBitmap(getBrush(), (int) size, (int) size, true);
float len = mPathMeasure.getLength();
float s2 = size / 2;
- float step = s2 / 6;
+ float step = s2 / 8;
for (float i = 0; i < len; i += step) {
mPathMeasure.getPosTan(i, mPosition, mTan);
// canvas.drawCircle(pos[0], pos[1], size, paint);
@@ -183,32 +199,33 @@ public class ImageFilterDraw extends ImageFilter {
}
void paint(FilterDrawRepresentation.StrokeData sd, Canvas canvas, Matrix toScrMatrix,
- boolean highQuality) {
- mDrawingsTypes[sd.mType].paint(sd, canvas, toScrMatrix, highQuality);
+ int quality) {
+ mDrawingsTypes[sd.mType].paint(sd, canvas, toScrMatrix, quality);
}
- public void drawData(Canvas canvas, Matrix originalRotateToScreen, boolean highQuality) {
+ public void drawData(Canvas canvas, Matrix originalRotateToScreen, int quality) {
Paint paint = new Paint();
- if (highQuality) {
+ if (quality == ImagePreset.QUALITY_FINAL) {
paint.setAntiAlias(true);
}
paint.setStyle(Style.STROKE);
paint.setColor(Color.RED);
paint.setStrokeWidth(40);
- if (mParameters.getDrawing().isEmpty()) {
+ if (mParameters.getDrawing().isEmpty() && mParameters.getCurrentDrawing() == null) {
return;
}
- if (highQuality) {
+ if (quality == ImagePreset.QUALITY_FINAL) {
for (FilterDrawRepresentation.StrokeData strokeData : mParameters.getDrawing()) {
- paint(strokeData, canvas, originalRotateToScreen, highQuality);
+ paint(strokeData, canvas, originalRotateToScreen, quality);
}
return;
}
if (mOverlayBitmap == null ||
mOverlayBitmap.getWidth() != canvas.getWidth() ||
- mOverlayBitmap.getHeight() != canvas.getHeight()) {
+ mOverlayBitmap.getHeight() != canvas.getHeight() ||
+ mParameters.getDrawing().size() < mCachedStrokes) {
mOverlayBitmap = Bitmap.createBitmap(
canvas.getWidth(), canvas.getHeight(), Bitmap.Config.ARGB_8888);
@@ -222,7 +239,7 @@ public class ImageFilterDraw extends ImageFilter {
StrokeData stroke = mParameters.getCurrentDrawing();
if (stroke != null) {
- paint(stroke, canvas, originalRotateToScreen, highQuality);
+ paint(stroke, canvas, originalRotateToScreen, quality);
}
}
@@ -232,28 +249,29 @@ public class ImageFilterDraw extends ImageFilter {
int n = v.size();
for (int i = mCachedStrokes; i < n; i++) {
- paint(v.get(i), drawCache, originalRotateToScreen, false);
+ paint(v.get(i), drawCache, originalRotateToScreen, ImagePreset.QUALITY_PREVIEW);
}
mCachedStrokes = n;
}
public void draw(Canvas canvas, Matrix originalRotateToScreen) {
for (FilterDrawRepresentation.StrokeData strokeData : mParameters.getDrawing()) {
- paint(strokeData, canvas, originalRotateToScreen, false);
+ paint(strokeData, canvas, originalRotateToScreen, ImagePreset.QUALITY_PREVIEW);
}
- mDrawingsTypes[mCurrentStyle].paint(null, canvas, originalRotateToScreen, false);
+ mDrawingsTypes[mCurrentStyle].paint(
+ null, canvas, originalRotateToScreen, ImagePreset.QUALITY_PREVIEW);
}
@Override
- public Bitmap apply(Bitmap bitmap, float scaleFactor, boolean highQuality) {
+ public Bitmap apply(Bitmap bitmap, float scaleFactor, int quality) {
int w = bitmap.getWidth();
int h = bitmap.getHeight();
short[] rect = new short[4];
Matrix m = new Matrix();
m.setScale(scaleFactor, scaleFactor);
+ drawData(new Canvas(bitmap), m, quality);
- drawData(new Canvas(bitmap), m, highQuality);
return bitmap;
}
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterEdge.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterEdge.java
index 96839e4ab..55c709573 100644
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilterEdge.java
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterEdge.java
@@ -38,7 +38,7 @@ public class ImageFilterEdge extends SimpleImageFilter {
native protected void nativeApplyFilter(Bitmap bitmap, int w, int h, float p);
@Override
- public Bitmap apply(Bitmap bitmap, float scaleFactor, boolean highQuality) {
+ public Bitmap apply(Bitmap bitmap, float scaleFactor, int quality) {
if (getParameters() == null) {
return bitmap;
}
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterExposure.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterExposure.java
index e36f096ad..8bb35f853 100644
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilterExposure.java
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterExposure.java
@@ -38,7 +38,7 @@ public class ImageFilterExposure extends SimpleImageFilter {
native protected void nativeApplyFilter(Bitmap bitmap, int w, int h, float bright);
@Override
- public Bitmap apply(Bitmap bitmap, float scaleFactor, boolean highQuality) {
+ public Bitmap apply(Bitmap bitmap, float scaleFactor, int quality) {
if (getParameters() == null) {
return bitmap;
}
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterFx.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterFx.java
index 0a3c8abd0..820ec3e51 100644
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilterFx.java
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterFx.java
@@ -40,7 +40,7 @@ public class ImageFilterFx extends ImageFilter {
native protected void nativeApplyFilter(Bitmap bitmap, int w, int h,Bitmap fxBitmap, int fxw, int fxh);
@Override
- public Bitmap apply(Bitmap bitmap, float scaleFactor, boolean highQuality) {
+ public Bitmap apply(Bitmap bitmap, float scaleFactor, int quality) {
if (getParameters() == null || getParameters().getFxBitmap() ==null) {
return bitmap;
}
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterGeometry.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterGeometry.java
index a778bee21..1380c528d 100644
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilterGeometry.java
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterGeometry.java
@@ -67,7 +67,7 @@ public class ImageFilterGeometry extends ImageFilter {
Bitmap dst, int dstWidth, int dstHeight, float straightenAngle);
@Override
- public Bitmap apply(Bitmap bitmap, float scaleFactor, boolean highQuality) {
+ public Bitmap apply(Bitmap bitmap, float scaleFactor, int quality) {
// 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?)
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterHue.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterHue.java
index ed28e57b7..54bd068fc 100644
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilterHue.java
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterHue.java
@@ -44,7 +44,7 @@ public class ImageFilterHue extends SimpleImageFilter {
native protected void nativeApplyFilter(Bitmap bitmap, int w, int h, float []matrix);
@Override
- public Bitmap apply(Bitmap bitmap, float scaleFactor, boolean highQuality) {
+ public Bitmap apply(Bitmap bitmap, float scaleFactor, int quality) {
if (getParameters() == null) {
return bitmap;
}
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterKMeans.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterKMeans.java
index f28839744..f48bd047a 100644
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilterKMeans.java
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterKMeans.java
@@ -53,7 +53,7 @@ public class ImageFilterKMeans extends SimpleImageFilter {
int swidth, int sheight, int p, int seed);
@Override
- public Bitmap apply(Bitmap bitmap, float scaleFactor, boolean highQuality) {
+ public Bitmap apply(Bitmap bitmap, float scaleFactor, int quality) {
if (getParameters() == null) {
return bitmap;
}
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterNegative.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterNegative.java
index 14307c37d..c0208765b 100644
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilterNegative.java
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterNegative.java
@@ -23,7 +23,7 @@ public class ImageFilterNegative extends ImageFilter {
native protected void nativeApplyFilter(Bitmap bitmap, int w, int h);
@Override
- public Bitmap apply(Bitmap bitmap, float scaleFactor, boolean highQuality) {
+ public Bitmap apply(Bitmap bitmap, float scaleFactor, int quality) {
int w = bitmap.getWidth();
int h = bitmap.getHeight();
nativeApplyFilter(bitmap, w, h);
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterParametricBorder.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterParametricBorder.java
index 36c86d847..316a286e8 100644
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilterParametricBorder.java
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterParametricBorder.java
@@ -63,14 +63,14 @@ public class ImageFilterParametricBorder extends ImageFilter {
}
@Override
- public Bitmap apply(Bitmap bitmap, float scaleFactor, boolean highQuality) {
+ public Bitmap apply(Bitmap bitmap, float scaleFactor, int quality) {
Canvas canvas = new Canvas(bitmap);
applyHelper(canvas, bitmap.getWidth(), bitmap.getHeight());
return bitmap;
}
@Override
- public Bitmap iconApply(Bitmap bitmap, float scaleFactor, boolean highQuality) {
+ public Bitmap iconApply(Bitmap bitmap, float scaleFactor, int quality) {
Canvas canvas = new Canvas(bitmap);
applyHelper(canvas, bitmap.getWidth() * 4, bitmap.getHeight() * 4);
return bitmap;
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterRS.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterRS.java
index 79c783a94..c741a4887 100644
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilterRS.java
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterRS.java
@@ -33,7 +33,11 @@ public class ImageFilterRS extends ImageFilter {
private final Bitmap.Config mBitmapConfig = Bitmap.Config.ARGB_8888;
- public void prepare(Bitmap bitmap, float scaleFactor, boolean highQuality) {
+ public void resetBitmap() {
+ mOldBitmap = null;
+ }
+
+ public void prepare(Bitmap bitmap, float scaleFactor, int quality) {
if (sOldBitmap == null
|| (bitmap.getWidth() != sOldBitmap.getWidth())
|| (bitmap.getHeight() != sOldBitmap.getHeight())) {
@@ -52,13 +56,13 @@ public class ImageFilterRS extends ImageFilter {
}
mInPixelsAllocation.copyFrom(bitmap);
if (mOldBitmap != sOldBitmap) {
- createFilter(mResources, scaleFactor, highQuality);
+ createFilter(mResources, scaleFactor, quality);
mOldBitmap = sOldBitmap;
}
}
public void createFilter(android.content.res.Resources res,
- float scaleFactor, boolean highQuality) {
+ float scaleFactor, int quality) {
// Stub
}
@@ -71,12 +75,12 @@ public class ImageFilterRS extends ImageFilter {
}
@Override
- public Bitmap apply(Bitmap bitmap, float scaleFactor, boolean highQuality) {
+ public Bitmap apply(Bitmap bitmap, float scaleFactor, int quality) {
if (bitmap == null) {
return bitmap;
}
try {
- prepare(bitmap, scaleFactor, highQuality);
+ prepare(bitmap, scaleFactor, quality);
runFilter();
update(bitmap);
} catch (android.renderscript.RSIllegalArgumentException e) {
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterRedEye.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterRedEye.java
index 832f644e1..a65a9631b 100644
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilterRedEye.java
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterRedEye.java
@@ -20,134 +20,94 @@ import android.graphics.Bitmap;
import android.graphics.Matrix;
import android.graphics.RectF;
-import com.android.gallery3d.R;
import com.android.gallery3d.filtershow.imageshow.GeometryMetadata;
import java.util.Vector;
public class ImageFilterRedEye extends ImageFilter {
private static final String LOGTAG = "ImageFilterRedEye";
- private Vector<RedEyeCandidate> mCandidates = null;
+ FilterRedEyeRepresentation mParameters = new FilterRedEyeRepresentation();
public ImageFilterRedEye() {
mName = "Red Eye";
}
- public int getButtonId() {
- return R.id.redEyeButton;
- }
-
- public int getTextId() {
- return R.string.redeye;
- }
-
- public int getEditingViewId() {
- return R.id.imageRedEyes;
- }
-
@Override
- public ImageFilter clone() throws CloneNotSupportedException {
- // FIXME: clone() should not be needed. Remove when we fix red eyes.
- ImageFilterRedEye filter = (ImageFilterRedEye) super.clone();
- if (mCandidates != null) {
- int size = mCandidates.size();
- filter.mCandidates = new Vector<RedEyeCandidate>();
- for (int i = 0; i < size; i++) {
- filter.mCandidates.add(new RedEyeCandidate(mCandidates.elementAt(i)));
- }
- }
- return filter;
+ public FilterRepresentation getDefaultRepresentation() {
+ FilterRedEyeRepresentation representation = new FilterRedEyeRepresentation();
+
+ return representation;
}
public boolean isNil() {
- if (mCandidates != null && mCandidates.size() > 0) {
+ if (mParameters.getCandidates() != null && mParameters.getCandidates().size() > 0) {
return false;
}
return true;
}
public Vector<RedEyeCandidate> getCandidates() {
- if (mCandidates == null) {
- mCandidates = new Vector<RedEyeCandidate>();
- }
- return mCandidates;
- }
-
- public void addRect(RectF rect, RectF bounds) {
- if (mCandidates == null) {
- mCandidates = new Vector<RedEyeCandidate>();
+ if (!mParameters.hasCandidates()) {
+ mParameters.setCandidates(new Vector<RedEyeCandidate>());
}
- Vector<RedEyeCandidate> intersects = new Vector<RedEyeCandidate>();
- for (int i = 0; i < mCandidates.size(); i++) {
- RedEyeCandidate r = mCandidates.elementAt(i);
- if (r.intersect(rect)) {
- intersects.add(r);
- }
- }
- for (int i = 0; i < intersects.size(); i++) {
- RedEyeCandidate r = intersects.elementAt(i);
- rect.union(r.mRect);
- bounds.union(r.mBounds);
- mCandidates.remove(r);
- }
- mCandidates.add(new RedEyeCandidate(rect, bounds));
+ return mParameters.getCandidates();
}
public void clear() {
- if (mCandidates == null) {
- mCandidates = new Vector<RedEyeCandidate>();
+ if (!mParameters.hasCandidates()) {
+ mParameters.setCandidates(new Vector<RedEyeCandidate>());
}
- mCandidates.clear();
+ mParameters.clearCandidates();
}
native protected void nativeApplyFilter(Bitmap bitmap, int w, int h, short[] matrix);
@Override
- public Bitmap apply(Bitmap bitmap, float scaleFactor, boolean highQuality) {
+ public Bitmap apply(Bitmap bitmap, float scaleFactor, int quality) {
int w = bitmap.getWidth();
int h = bitmap.getHeight();
short[] rect = new short[4];
-
- if (mCandidates != null && mCandidates.size() > 0) {
- for (int i = 0; i < mCandidates.size(); i++) {
- RectF r = new RectF(mCandidates.elementAt(i).mRect);
- GeometryMetadata geo = getImagePreset().mGeoData;
- Matrix originalToScreen = geo.getOriginalToScreen(true,
- getImagePreset().getImageLoader().getOriginalBounds().width(),
- getImagePreset().getImageLoader().getOriginalBounds().height(),
- w, h);
- originalToScreen.mapRect(r);
- if (r.left < 0) {
- r.left = 0;
- }
- if (r.left > w) {
- r.left = w;
- }
- if (r.top < 0) {
- r.top = 0;
- }
- if (r.top > h) {
- r.top = h;
- }
- if (r.right < 0) {
- r.right = 0;
- }
- if (r.right > w) {
- r.right = w;
- }
- if (r.bottom < 0) {
- r.bottom = 0;
- }
- if (r.bottom > h) {
- r.bottom = h;
- }
- rect[0] = (short) r.left;
- rect[1] = (short) r.top;
- rect[2] = (short) r.width();
- rect[3] = (short) r.height();
- nativeApplyFilter(bitmap, w, h, rect);
+ int size = mParameters.getNumberOfCandidates();
+
+ for (int i = 0; i < size; i++) {
+ RectF r = new RectF(mParameters.getCandidate(i).mRect);
+ GeometryMetadata geo = getImagePreset().mGeoData;
+ Matrix originalToScreen = geo.getOriginalToScreen(true,
+ getImagePreset().getImageLoader().getOriginalBounds().width(),
+ getImagePreset().getImageLoader().getOriginalBounds().height(),
+ w, h);
+ originalToScreen.mapRect(r);
+ if (r.left < 0) {
+ r.left = 0;
+ }
+ if (r.left > w) {
+ r.left = w;
+ }
+ if (r.top < 0) {
+ r.top = 0;
}
+ if (r.top > h) {
+ r.top = h;
+ }
+ if (r.right < 0) {
+ r.right = 0;
+ }
+ if (r.right > w) {
+ r.right = w;
+ }
+ if (r.bottom < 0) {
+ r.bottom = 0;
+ }
+ if (r.bottom > h) {
+ r.bottom = h;
+ }
+ rect[0] = (short) r.left;
+ rect[1] = (short) r.top;
+ rect[2] = (short) r.width();
+ rect[3] = (short) r.height();
+ nativeApplyFilter(bitmap, w, h, rect);
}
+
return bitmap;
}
}
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterSaturated.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterSaturated.java
index 747a03685..f6ef78138 100644
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilterSaturated.java
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterSaturated.java
@@ -38,7 +38,7 @@ public class ImageFilterSaturated extends SimpleImageFilter {
native protected void nativeApplyFilter(Bitmap bitmap, int w, int h, float saturation);
@Override
- public Bitmap apply(Bitmap bitmap, float scaleFactor, boolean highQuality) {
+ public Bitmap apply(Bitmap bitmap, float scaleFactor, int quality) {
if (getParameters() == null) {
return bitmap;
}
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterShadows.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterShadows.java
index a2560b99e..b50b28e52 100644
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilterShadows.java
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterShadows.java
@@ -39,7 +39,7 @@ public class ImageFilterShadows extends SimpleImageFilter {
native protected void nativeApplyFilter(Bitmap bitmap, int w, int h, float factor);
@Override
- public Bitmap apply(Bitmap bitmap, float scaleFactor, boolean highQuality) {
+ public Bitmap apply(Bitmap bitmap, float scaleFactor, int quality) {
if (getParameters() == null) {
return bitmap;
}
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterSharpen.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterSharpen.java
index 92f9b1a6d..9c99d57d0 100644
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilterSharpen.java
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterSharpen.java
@@ -48,7 +48,7 @@ public class ImageFilterSharpen extends ImageFilterRS {
@Override
public void createFilter(android.content.res.Resources res, float scaleFactor,
- boolean highQuality) {
+ int quality) {
int w = mInPixelsAllocation.getType().getX();
int h = mInPixelsAllocation.getType().getY();
mScaleFactor = scaleFactor;
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterStraighten.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterStraighten.java
index 3feec7bcc..92bde992d 100644
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilterStraighten.java
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterStraighten.java
@@ -53,7 +53,7 @@ public class ImageFilterStraighten extends ImageFilter {
}
@Override
- public Bitmap apply(Bitmap bitmap, float scaleFactor, boolean highQuality) {
+ public Bitmap apply(Bitmap bitmap, float scaleFactor, int quality) {
// 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?)
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterTinyPlanet.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterTinyPlanet.java
index d8ec3900e..702cc664c 100644
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilterTinyPlanet.java
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterTinyPlanet.java
@@ -72,7 +72,7 @@ public class ImageFilterTinyPlanet extends SimpleImageFilter {
float angle);
@Override
- public Bitmap apply(Bitmap bitmapIn, float scaleFactor, boolean highQuality) {
+ public Bitmap apply(Bitmap bitmapIn, float scaleFactor, int quality) {
int w = bitmapIn.getWidth();
int h = bitmapIn.getHeight();
int outputSize = (int) (w / 2f);
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterVibrance.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterVibrance.java
index 385921168..ac20205f0 100644
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilterVibrance.java
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterVibrance.java
@@ -38,7 +38,7 @@ public class ImageFilterVibrance extends SimpleImageFilter {
native protected void nativeApplyFilter(Bitmap bitmap, int w, int h, float bright);
@Override
- public Bitmap apply(Bitmap bitmap, float scaleFactor, boolean highQuality) {
+ public Bitmap apply(Bitmap bitmap, float scaleFactor, int quality) {
if (getParameters() == null) {
return bitmap;
}
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterVignette.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterVignette.java
index 3aad6bd15..ac0fdee13 100644
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilterVignette.java
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterVignette.java
@@ -42,7 +42,7 @@ public class ImageFilterVignette extends SimpleImageFilter {
native protected void nativeApplyFilter(Bitmap bitmap, int w, int h, float strength);
@Override
- public Bitmap apply(Bitmap bitmap, float scaleFactor, boolean highQuality) {
+ public Bitmap apply(Bitmap bitmap, float scaleFactor, int quality) {
if (getParameters() == null) {
return bitmap;
}
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterWBalance.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterWBalance.java
index 28223b28d..8b6dd5426 100644
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilterWBalance.java
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterWBalance.java
@@ -30,7 +30,7 @@ public class ImageFilterWBalance extends ImageFilter {
public FilterRepresentation getDefaultRepresentation() {
FilterRepresentation representation = new FilterDirectRepresentation("WBalance");
representation.setFilterClass(ImageFilterWBalance.class);
- representation.setFilterType(FilterRepresentation.TYPE_WBALANCE);
+ representation.setPriority(FilterRepresentation.TYPE_WBALANCE);
representation.setTextId(R.string.wbalance);
representation.setButtonId(R.id.wbalanceButton);
representation.setShowEditingControls(false);
@@ -40,7 +40,7 @@ public class ImageFilterWBalance extends ImageFilter {
native protected void nativeApplyFilter(Bitmap bitmap, int w, int h, int locX, int locY);
@Override
- public Bitmap apply(Bitmap bitmap, float scaleFactor, boolean highQuality) {
+ public Bitmap apply(Bitmap bitmap, float scaleFactor, int quality) {
int w = bitmap.getWidth();
int h = bitmap.getHeight();
nativeApplyFilter(bitmap, w, h, -1, -1);
diff --git a/src/com/android/gallery3d/filtershow/filters/SimpleImageFilter.java b/src/com/android/gallery3d/filtershow/filters/SimpleImageFilter.java
index d494913cf..922a16a0f 100644
--- a/src/com/android/gallery3d/filtershow/filters/SimpleImageFilter.java
+++ b/src/com/android/gallery3d/filtershow/filters/SimpleImageFilter.java
@@ -38,9 +38,9 @@ public class SimpleImageFilter extends ImageFilter {
}
@Override
- public Bitmap iconApply(Bitmap bitmap, float scaleFactor, boolean highQuality) {
+ public Bitmap iconApply(Bitmap bitmap, float scaleFactor, int quality) {
FilterRepresentation representation = getDefaultRepresentation();
this.useRepresentation(representation);
- return apply(bitmap, scaleFactor, highQuality);
+ return apply(bitmap, scaleFactor, quality);
}
}
diff --git a/src/com/android/gallery3d/filtershow/imageshow/GeometryListener.java b/src/com/android/gallery3d/filtershow/imageshow/GeometryListener.java
new file mode 100644
index 000000000..549c2e7a5
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/imageshow/GeometryListener.java
@@ -0,0 +1,21 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.gallery3d.filtershow.imageshow;
+
+public interface GeometryListener {
+ public void geometryChanged();
+}
diff --git a/src/com/android/gallery3d/filtershow/imageshow/GeometryMetadata.java b/src/com/android/gallery3d/filtershow/imageshow/GeometryMetadata.java
index b53284061..a3645d6f5 100644
--- a/src/com/android/gallery3d/filtershow/imageshow/GeometryMetadata.java
+++ b/src/com/android/gallery3d/filtershow/imageshow/GeometryMetadata.java
@@ -86,12 +86,12 @@ public class GeometryMetadata {
return false;
}
- public Bitmap apply(Bitmap original, float scaleFactor, boolean highQuality) {
+ public Bitmap apply(Bitmap original, float scaleFactor, int quality) {
if (!hasModifications()) {
return original;
}
mImageFilter.setGeometryMetadata(this);
- Bitmap m = mImageFilter.apply(original, scaleFactor, highQuality);
+ Bitmap m = mImageFilter.apply(original, scaleFactor, quality);
return m;
}
diff --git a/src/com/android/gallery3d/filtershow/imageshow/ImageDraw.java b/src/com/android/gallery3d/filtershow/imageshow/ImageDraw.java
index 65ccf1f7a..0cd229968 100644
--- a/src/com/android/gallery3d/filtershow/imageshow/ImageDraw.java
+++ b/src/com/android/gallery3d/filtershow/imageshow/ImageDraw.java
@@ -7,6 +7,7 @@ import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
+import android.util.Log;
import android.view.MotionEvent;
import com.android.gallery3d.filtershow.editors.EditorDraw;
@@ -88,7 +89,6 @@ public class ImageDraw extends ImageShow {
ImageFilterDraw filter = (ImageFilterDraw) getCurrentFilter();
if (event.getAction() == MotionEvent.ACTION_DOWN) {
-
mTmpPoint[0] = event.getX();
mTmpPoint[1] = event.getY();
mToOrig.mapPoints(mTmpPoint);
@@ -113,8 +113,6 @@ public class ImageDraw extends ImageShow {
mTmpPoint[1] = event.getY();
mToOrig.mapPoints(mTmpPoint);
mFRep.endSection(mTmpPoint[0], mTmpPoint[1]);
- this.resetImageCaches(this);
-
}
mEditorDraw.commitLocalRepresentation();
invalidate();
diff --git a/src/com/android/gallery3d/filtershow/imageshow/ImageRedEyes.java b/src/com/android/gallery3d/filtershow/imageshow/ImageRedEye.java
index c012ff1cc..2db9227b9 100644
--- a/src/com/android/gallery3d/filtershow/imageshow/ImageRedEyes.java
+++ b/src/com/android/gallery3d/filtershow/imageshow/ImageRedEye.java
@@ -11,24 +11,28 @@ import android.graphics.RectF;
import android.util.AttributeSet;
import android.view.MotionEvent;
+import com.android.gallery3d.filtershow.editors.EditorRedEye;
+import com.android.gallery3d.filtershow.filters.FilterRedEyeRepresentation;
import com.android.gallery3d.filtershow.filters.ImageFilterRedEye;
import com.android.gallery3d.filtershow.filters.RedEyeCandidate;
-public class ImageRedEyes extends ImageShow {
+public class ImageRedEye extends ImageShow {
private static final String LOGTAG = "ImageRedEyes";
private RectF mCurrentRect = null;
+ private EditorRedEye mEditorRedEye;
+ private FilterRedEyeRepresentation mRedEyeRep;
private static float mTouchPadding = 80;
public static void setTouchPadding(float padding) {
mTouchPadding = padding;
}
- public ImageRedEyes(Context context, AttributeSet attrs) {
+ public ImageRedEye(Context context, AttributeSet attrs) {
super(context, attrs);
}
- public ImageRedEyes(Context context) {
+ public ImageRedEye(Context context) {
super(context);
}
@@ -54,8 +58,6 @@ public class ImageRedEyes extends ImageShow {
float ex = event.getX();
float ey = event.getY();
- ImageFilterRedEye filter = (ImageFilterRedEye) getCurrentFilter();
-
// let's transform (ex, ey) to displayed image coordinates
if (event.getAction() == MotionEvent.ACTION_DOWN) {
mCurrentRect = new RectF();
@@ -87,11 +89,12 @@ public class ImageRedEyes extends ImageShow {
invert.reset();
originalNoRotateToScreen.invert(invert);
invert.mapRect(r2);
- filter.addRect(r, r2);
+ mRedEyeRep.addRect(r, r2);
this.resetImageCaches(this);
}
mCurrentRect = null;
}
+ mEditorRedEye.commitLocalRepresentation();
invalidate();
return true;
}
@@ -117,32 +120,41 @@ public class ImageRedEyes extends ImageShow {
mImageLoader.getOriginalBounds().width(),
mImageLoader.getOriginalBounds().height(), getWidth(), getHeight());
- ImageFilterRedEye filter = (ImageFilterRedEye) getCurrentFilter();
- for (RedEyeCandidate candidate : filter.getCandidates()) {
- RectF rect = candidate.getRect();
- RectF drawRect = new RectF();
- originalToScreen.mapRect(drawRect, rect);
- RectF fullRect = new RectF();
- originalRotateToScreen.mapRect(fullRect, rect);
- paint.setColor(Color.BLUE);
- canvas.drawRect(fullRect, paint);
- canvas.drawLine(fullRect.centerX(), fullRect.top,
- fullRect.centerX(), fullRect.bottom, paint);
- canvas.drawLine(fullRect.left, fullRect.centerY(),
- fullRect.right, fullRect.centerY(), paint);
- paint.setColor(Color.GREEN);
- float dw = drawRect.width();
- float dh = drawRect.height();
- float dx = fullRect.centerX() - dw/2;
- float dy = fullRect.centerY() - dh/2;
- drawRect.set(dx, dy, dx + dw, dy + dh);
- canvas.drawRect(drawRect, paint);
- canvas.drawLine(drawRect.centerX(), drawRect.top,
- drawRect.centerX(), drawRect.bottom, paint);
- canvas.drawLine(drawRect.left, drawRect.centerY(),
- drawRect.right, drawRect.centerY(), paint);
- canvas.drawCircle(drawRect.centerX(), drawRect.centerY(),
- mTouchPadding, paint);
+ if (mRedEyeRep != null) {
+ for (RedEyeCandidate candidate : mRedEyeRep.getCandidates()) {
+ RectF rect = candidate.getRect();
+ RectF drawRect = new RectF();
+ originalToScreen.mapRect(drawRect, rect);
+ RectF fullRect = new RectF();
+ originalRotateToScreen.mapRect(fullRect, rect);
+ paint.setColor(Color.BLUE);
+ canvas.drawRect(fullRect, paint);
+ canvas.drawLine(fullRect.centerX(), fullRect.top,
+ fullRect.centerX(), fullRect.bottom, paint);
+ canvas.drawLine(fullRect.left, fullRect.centerY(),
+ fullRect.right, fullRect.centerY(), paint);
+ paint.setColor(Color.GREEN);
+ float dw = drawRect.width();
+ float dh = drawRect.height();
+ float dx = fullRect.centerX() - dw / 2;
+ float dy = fullRect.centerY() - dh / 2;
+ drawRect.set(dx, dy, dx + dw, dy + dh);
+ canvas.drawRect(drawRect, paint);
+ canvas.drawLine(drawRect.centerX(), drawRect.top,
+ drawRect.centerX(), drawRect.bottom, paint);
+ canvas.drawLine(drawRect.left, drawRect.centerY(),
+ drawRect.right, drawRect.centerY(), paint);
+ canvas.drawCircle(drawRect.centerX(), drawRect.centerY(),
+ mTouchPadding, paint);
+ }
}
}
+
+ public void setEditor(EditorRedEye editorRedEye) {
+ mEditorRedEye = editorRedEye;
+ }
+
+ public void setRepresentation(FilterRedEyeRepresentation redEyeRep) {
+ mRedEyeRep = redEyeRep;
+ }
}
diff --git a/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java b/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java
index 21046b56c..463756839 100644
--- a/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java
+++ b/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java
@@ -406,8 +406,12 @@ public class ImageShow extends View implements OnGestureListener,
paint.setTextSize(mOriginalTextSize);
paint.getTextBounds(mOriginalText, 0, mOriginalText.length(), bounds);
paint.setColor(Color.BLACK);
- canvas.drawText(mOriginalText, mImageBounds.left + mOriginalTextMargin + 1,
- mImageBounds.top + bounds.height() + mOriginalTextMargin + 1, paint);
+ paint.setStyle(Paint.Style.STROKE);
+ paint.setStrokeWidth(3);
+ canvas.drawText(mOriginalText, mImageBounds.left + mOriginalTextMargin,
+ mImageBounds.top + bounds.height() + mOriginalTextMargin, paint);
+ paint.setStyle(Paint.Style.FILL);
+ paint.setStrokeWidth(1);
paint.setColor(Color.WHITE);
canvas.drawText(mOriginalText, mImageBounds.left + mOriginalTextMargin,
mImageBounds.top + bounds.height() + mOriginalTextMargin, paint);
diff --git a/src/com/android/gallery3d/filtershow/imageshow/MasterImage.java b/src/com/android/gallery3d/filtershow/imageshow/MasterImage.java
index 296954cf9..3172c79dc 100644
--- a/src/com/android/gallery3d/filtershow/imageshow/MasterImage.java
+++ b/src/com/android/gallery3d/filtershow/imageshow/MasterImage.java
@@ -19,7 +19,6 @@ package com.android.gallery3d.filtershow.imageshow;
import android.graphics.Bitmap;
import android.graphics.RectF;
-import com.android.gallery3d.app.Log;
import com.android.gallery3d.filtershow.FilterShowActivity;
import com.android.gallery3d.filtershow.HistoryAdapter;
import com.android.gallery3d.filtershow.ImageStateAdapter;
@@ -54,6 +53,9 @@ public class MasterImage implements RenderingRequestCaller {
private Vector<ImageShow> mObservers = new Vector<ImageShow>();
private FilterRepresentation mCurrentFilterRepresentation;
+ private Vector<GeometryListener> mGeometryListeners = new Vector<GeometryListener>();
+
+ private GeometryMetadata mPreviousGeometry = null;
private MasterImage() {
}
@@ -76,6 +78,10 @@ public class MasterImage implements RenderingRequestCaller {
mActivity = activity;
}
+ public ImageLoader getLoader() {
+ return mLoader;
+ }
+
public synchronized ImagePreset getPreset() {
return mPreset;
}
@@ -97,6 +103,11 @@ public class MasterImage implements RenderingRequestCaller {
mHistory.addHistoryItem(mPreset);
}
updatePresets(true);
+ GeometryMetadata geo = mPreset.mGeoData;
+ if (!geo.equals(mPreviousGeometry)) {
+ notifyGeometryChange();
+ }
+ mPreviousGeometry = new GeometryMetadata(geo);
}
private void setGeometry() {
@@ -242,4 +253,14 @@ public class MasterImage implements RenderingRequestCaller {
public static void reset() {
sMasterImage = null;
}
+
+ public void addGeometryListener(GeometryListener listener) {
+ mGeometryListeners.add(listener);
+ }
+
+ public void notifyGeometryChange() {
+ for (GeometryListener listener : mGeometryListeners) {
+ listener.geometryChanged();
+ }
+ }
}
diff --git a/src/com/android/gallery3d/filtershow/presets/ImagePreset.java b/src/com/android/gallery3d/filtershow/presets/ImagePreset.java
index c7d14e80b..0582b34bc 100644
--- a/src/com/android/gallery3d/filtershow/presets/ImagePreset.java
+++ b/src/com/android/gallery3d/filtershow/presets/ImagePreset.java
@@ -21,6 +21,7 @@ import android.util.Log;
import com.android.gallery3d.filtershow.ImageStateAdapter;
import com.android.gallery3d.filtershow.cache.ImageLoader;
+import com.android.gallery3d.filtershow.filters.BaseFiltersManager;
import com.android.gallery3d.filtershow.filters.FilterRepresentation;
import com.android.gallery3d.filtershow.filters.FiltersManager;
import com.android.gallery3d.filtershow.filters.ImageFilter;
@@ -35,7 +36,10 @@ public class ImagePreset {
private FilterRepresentation mBorder = null;
private float mScaleFactor = 1.0f;
- private boolean mIsHighQuality = false;
+ public static final int QUALITY_ICON = 0;
+ public static final int QUALITY_PREVIEW = 1;
+ public static final int QUALITY_FINAL = 2;
+ private int mQuality = QUALITY_PREVIEW;
private ImageLoader mImageLoader = null;
private Vector<FilterRepresentation> mFilters = new Vector<FilterRepresentation>();
@@ -380,14 +384,14 @@ public class ImagePreset {
public Bitmap applyGeometry(Bitmap bitmap) {
// Apply any transform -- 90 rotate, flip, straighten, crop
// Returns a new bitmap.
- return mGeoData.apply(bitmap, mScaleFactor, mIsHighQuality);
+ return mGeoData.apply(bitmap, mScaleFactor, mQuality);
}
public Bitmap applyBorder(Bitmap bitmap) {
if (mBorder != null && mDoApplyGeometry) {
ImageFilter filter = FiltersManager.getManager().getFilterForRepresentation(mBorder);
filter.useRepresentation(mBorder);
- bitmap = filter.apply(bitmap, mScaleFactor, mIsHighQuality);
+ bitmap = filter.apply(bitmap, mScaleFactor, mQuality);
}
return bitmap;
}
@@ -408,7 +412,7 @@ public class ImagePreset {
}
ImageFilter filter = FiltersManager.getManager().getFilterForRepresentation(representation);
filter.useRepresentation(representation);
- bitmap = filter.apply(bitmap, mScaleFactor, mIsHighQuality);
+ bitmap = filter.apply(bitmap, mScaleFactor, mQuality);
}
}
@@ -421,7 +425,7 @@ public class ImagePreset {
}
imageStateAdapter.clear();
// TODO: re-enable the state panel
- // imageStateAdapter.addAll(mFilters);
+ imageStateAdapter.addAll(mFilters);
imageStateAdapter.notifyDataSetChanged();
}
@@ -429,12 +433,12 @@ public class ImagePreset {
return mScaleFactor;
}
- public boolean isHighQuality() {
- return mIsHighQuality;
+ public int getQuality() {
+ return mQuality;
}
- public void setIsHighQuality(boolean value) {
- mIsHighQuality = value;
+ public void setQuality(int value) {
+ mQuality = value;
}
public void setScaleFactor(float value) {
diff --git a/src/com/android/gallery3d/filtershow/tools/SaveCopyTask.java b/src/com/android/gallery3d/filtershow/tools/SaveCopyTask.java
index 38a9a3a2f..e378fe2b7 100644
--- a/src/com/android/gallery3d/filtershow/tools/SaveCopyTask.java
+++ b/src/com/android/gallery3d/filtershow/tools/SaveCopyTask.java
@@ -168,7 +168,7 @@ public class SaveCopyTask extends AsyncTask<ImagePreset, Void, Uri> {
@Override
protected Uri doInBackground(ImagePreset... params) {
// TODO: Support larger dimensions for photo saving.
- if (params[0] == null) {
+ if (params[0] == null || sourceUri == null) {
return null;
}
ImagePreset preset = params[0];
diff --git a/src/com/android/gallery3d/filtershow/ui/FilterIconButton.java b/src/com/android/gallery3d/filtershow/ui/FilterIconButton.java
index a753f46b9..de2e1e5dc 100644
--- a/src/com/android/gallery3d/filtershow/ui/FilterIconButton.java
+++ b/src/com/android/gallery3d/filtershow/ui/FilterIconButton.java
@@ -24,20 +24,26 @@ import android.util.AttributeSet;
import android.view.View;
import android.widget.LinearLayout;
-import com.android.gallery3d.filtershow.FilterShowActivity;
import com.android.gallery3d.filtershow.PanelController;
-import com.android.gallery3d.filtershow.cache.FilteringPipeline;
+import com.android.gallery3d.filtershow.cache.ImageLoader;
+import com.android.gallery3d.filtershow.cache.RenderingRequest;
+import com.android.gallery3d.filtershow.cache.RenderingRequestCaller;
import com.android.gallery3d.filtershow.filters.FilterRepresentation;
-import com.android.gallery3d.filtershow.filters.FiltersManager;
-import com.android.gallery3d.filtershow.filters.ImageFilter;
+import com.android.gallery3d.filtershow.imageshow.GeometryListener;
+import com.android.gallery3d.filtershow.imageshow.MasterImage;
+import com.android.gallery3d.filtershow.presets.ImagePreset;
-public class FilterIconButton extends IconButton implements View.OnClickListener {
+public class FilterIconButton extends IconButton implements View.OnClickListener,
+ RenderingRequestCaller, GeometryListener {
+ private static final String LOGTAG = "FilterIconButton";
private Bitmap mOverlayBitmap = null;
private PanelController mController = null;
- private ImageFilter mImageFilter = null;
private FilterRepresentation mFilterRepresentation = null;
private LinearLayout mParentContainer = null;
private View.OnClickListener mListener = null;
+ private Bitmap mIconBitmap = null;
+ private ImagePreset mPreset = null;
+ private Rect mDestination = null;
public FilterIconButton(Context context) {
super(context);
@@ -56,25 +62,27 @@ public class FilterIconButton extends IconButton implements View.OnClickListener
setText(text);
mParentContainer = parent;
super.setOnClickListener(this);
+ MasterImage.getImage().addGeometryListener(this);
invalidate();
}
@Override
protected Bitmap drawImage(Bitmap dst, Bitmap image, Rect destination) {
- dst = super.drawImage(dst, image, destination);
- if (mImageFilter == null && mFilterRepresentation != null) {
- mImageFilter = FiltersManager.getManager().getFilterForRepresentation(mFilterRepresentation);
+ if (mIconBitmap == null && mPreset == null) {
+ ImageLoader loader = MasterImage.getImage().getLoader();
+ if (loader != null) {
+ ImagePreset geoPreset = new ImagePreset(MasterImage.getImage().getGeometryPreset());
+ image = geoPreset.applyGeometry(image);
+ dst = super.drawImage(dst, image, destination);
+ ImagePreset mPreset = new ImagePreset();
+ mPreset.addFilter(mFilterRepresentation);
+ mDestination = destination;
+ RenderingRequest.post(dst.copy(Bitmap.Config.ARGB_8888, true), mPreset, RenderingRequest.ICON_RENDERING, this);
+ }
+ return dst;
+ } else {
+ return mIconBitmap;
}
- if (mFilterRepresentation != null && mImageFilter != null) {
- mImageFilter.useRepresentation(mFilterRepresentation);
- }
- if (mImageFilter != null) {
- dst = mImageFilter.iconApply(dst, 1.0f, false);
- }
- if (mOverlayBitmap != null) {
- dst = super.drawImage(dst, mOverlayBitmap, destination);
- }
- return dst;
}
@Override
@@ -104,5 +112,27 @@ public class FilterIconButton extends IconButton implements View.OnClickListener
mOverlayBitmap = BitmapFactory.decodeResource(getResources(),
mFilterRepresentation.getOverlayId());
}
+ invalidate();
+ }
+
+ @Override
+ public void available(RenderingRequest request) {
+ if (request.getBitmap() == null) {
+ return;
+ }
+ mIconBitmap = request.getBitmap();
+ if (mOverlayBitmap != null) {
+ mIconBitmap = super.drawImage(mIconBitmap, mOverlayBitmap, mDestination);
+ }
+ invalidate();
+ stale_icon = true;
+ }
+
+ @Override
+ public void geometryChanged() {
+ stale_icon = true;
+ mIconBitmap = null;
+ mPreset = null;
+ invalidate();
}
}
diff --git a/src/com/android/gallery3d/filtershow/ui/IconButton.java b/src/com/android/gallery3d/filtershow/ui/IconButton.java
index 55dfb8043..28d01dfd9 100644
--- a/src/com/android/gallery3d/filtershow/ui/IconButton.java
+++ b/src/com/android/gallery3d/filtershow/ui/IconButton.java
@@ -38,7 +38,7 @@ public class IconButton extends Button {
protected Bitmap mImageMirror = null;
protected Bitmap mIcon = null;
- private boolean stale_icon = true;
+ protected boolean stale_icon = true;
public IconButton(Context context) {
this(context, null);
diff --git a/src/com/android/gallery3d/filtershow/ui/ImageCurves.java b/src/com/android/gallery3d/filtershow/ui/ImageCurves.java
index ec2df6c08..2e31db935 100644
--- a/src/com/android/gallery3d/filtershow/ui/ImageCurves.java
+++ b/src/com/android/gallery3d/filtershow/ui/ImageCurves.java
@@ -26,7 +26,6 @@ import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;
import android.os.AsyncTask;
import android.util.AttributeSet;
-import android.util.Log;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.MotionEvent;
@@ -36,6 +35,7 @@ import android.widget.PopupMenu;
import com.android.gallery3d.R;
import com.android.gallery3d.filtershow.editors.EditorCurves;
+import com.android.gallery3d.filtershow.filters.BaseFiltersManager;
import com.android.gallery3d.filtershow.filters.FilterCurvesRepresentation;
import com.android.gallery3d.filtershow.filters.FiltersManager;
import com.android.gallery3d.filtershow.filters.ImageFilterCurves;
diff --git a/src_pd/com/android/gallery3d/filtershow/filters/FiltersManager.java b/src_pd/com/android/gallery3d/filtershow/filters/FiltersManager.java
index 5ddabe29f..988cf2d81 100644
--- a/src_pd/com/android/gallery3d/filtershow/filters/FiltersManager.java
+++ b/src_pd/com/android/gallery3d/filtershow/filters/FiltersManager.java
@@ -16,39 +16,8 @@
package com.android.gallery3d.filtershow.filters;
-import com.android.gallery3d.filtershow.cache.ImageLoader;
-
-import java.util.HashMap;
-import java.util.Vector;
-
-public class FiltersManager {
-
- private static final String LOGTAG = "FiltersManager";
+public class FiltersManager extends BaseFiltersManager {
private static FiltersManager gInstance = null;
- private static HashMap<Class, ImageFilter> mFilters = new HashMap<Class, ImageFilter>();
-
- private FiltersManager() {
- Vector<ImageFilter> filters = new Vector<ImageFilter>();
- FiltersManager.addFilters(filters);
- filters.add(new ImageFilterFx());
- filters.add(new ImageFilterBorder());
- filters.add(new ImageFilterParametricBorder());
- for (ImageFilter filter : filters) {
- mFilters.put(filter.getClass(), filter);
- }
- }
-
- public ImageFilter getFilter(Class c) {
- return mFilters.get(c);
- }
-
- public ImageFilter getFilterForRepresentation(FilterRepresentation representation) {
- return mFilters.get(representation.getFilterClass());
- }
-
- public void addFilter(Class filterClass, ImageFilter filter) {
- mFilters.put(filterClass, filter);
- }
public static FiltersManager getManager() {
if (gInstance == null) {
@@ -56,58 +25,4 @@ public class FiltersManager {
}
return gInstance;
}
-
- public static FilterRepresentation getRepresentation(Class c) {
- ImageFilter filter = mFilters.get(c);
- if (filter != null) {
- return filter.getDefaultRepresentation();
- }
- return null;
- }
-
- public static void addFilterRepresentations(Vector<FilterRepresentation> representations) {
- representations.add(getRepresentation(ImageFilterTinyPlanet.class));
- representations.add(getRepresentation(ImageFilterWBalance.class));
- representations.add(getRepresentation(ImageFilterExposure.class));
- representations.add(getRepresentation(ImageFilterVignette.class));
- representations.add(getRepresentation(ImageFilterContrast.class));
- representations.add(getRepresentation(ImageFilterShadows.class));
- representations.add(getRepresentation(ImageFilterVibrance.class));
- representations.add(getRepresentation(ImageFilterSharpen.class));
- representations.add(getRepresentation(ImageFilterCurves.class));
- representations.add(getRepresentation(ImageFilterDraw.class));
- representations.add(getRepresentation(ImageFilterHue.class));
- representations.add(getRepresentation(ImageFilterSaturated.class));
- representations.add(getRepresentation(ImageFilterBwFilter.class));
- representations.add(getRepresentation(ImageFilterNegative.class));
- representations.add(getRepresentation(ImageFilterEdge.class));
- representations.add(getRepresentation(ImageFilterKMeans.class));
- }
-
- public static void addFilters(Vector<ImageFilter> filters) {
- filters.add(new ImageFilterTinyPlanet());
- filters.add(new ImageFilterWBalance());
- filters.add(new ImageFilterExposure());
- filters.add(new ImageFilterVignette());
- filters.add(new ImageFilterContrast());
- filters.add(new ImageFilterShadows());
- filters.add(new ImageFilterVibrance());
- filters.add(new ImageFilterSharpen());
- filters.add(new ImageFilterCurves());
- filters.add(new ImageFilterDraw());
- filters.add(new ImageFilterHue());
- filters.add(new ImageFilterSaturated());
- filters.add(new ImageFilterBwFilter());
- filters.add(new ImageFilterNegative());
- filters.add(new ImageFilterEdge());
- filters.add(new ImageFilterKMeans());
- }
-
- public static void addFilters(Vector<ImageFilter> filters, ImageLoader imageLoader) {
- FiltersManager.addFilters(filters);
- filters.add(new ImageFilterDownsample(imageLoader));
- FiltersManager.getManager().addFilter(ImageFilterDownsample.class,
- new ImageFilterDownsample(imageLoader));
- }
-
}