diff options
author | Ruben Brunk <rubenbrunk@google.com> | 2012-12-13 12:39:14 -0800 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-12-13 12:39:14 -0800 |
commit | dd83e926de0b41796bcb2218653e629296986e61 (patch) | |
tree | b08c468b7a857e3e4afc7d999964ccdfc8491f93 /src | |
parent | 6534f09fe42e9e9efd1582ba00a5a1515a8ec591 (diff) | |
parent | 27fb72ee1413871b4958ab2f24a229574de6ffa2 (diff) | |
download | android_packages_apps_Gallery2-dd83e926de0b41796bcb2218653e629296986e61.tar.gz android_packages_apps_Gallery2-dd83e926de0b41796bcb2218653e629296986e61.tar.bz2 android_packages_apps_Gallery2-dd83e926de0b41796bcb2218653e629296986e61.zip |
Merge "Added K-Means clustering filter." into gb-ub-photos-bryce
Diffstat (limited to 'src')
3 files changed, 76 insertions, 1 deletions
diff --git a/src/com/android/gallery3d/filtershow/FilterShowActivity.java b/src/com/android/gallery3d/filtershow/FilterShowActivity.java index a3da0c6be..161321904 100644 --- a/src/com/android/gallery3d/filtershow/FilterShowActivity.java +++ b/src/com/android/gallery3d/filtershow/FilterShowActivity.java @@ -65,6 +65,7 @@ import com.android.gallery3d.filtershow.filters.ImageFilterEdge; import com.android.gallery3d.filtershow.filters.ImageFilterExposure; import com.android.gallery3d.filtershow.filters.ImageFilterFx; import com.android.gallery3d.filtershow.filters.ImageFilterHue; +import com.android.gallery3d.filtershow.filters.ImageFilterKMeans; import com.android.gallery3d.filtershow.filters.ImageFilterNegative; import com.android.gallery3d.filtershow.filters.ImageFilterParametricBorder; import com.android.gallery3d.filtershow.filters.ImageFilterRS; @@ -311,7 +312,8 @@ public class FilterShowActivity extends Activity implements OnItemClickListener, new ImageFilterSaturated(), new ImageFilterBwFilter(), new ImageFilterNegative(), - new ImageFilterEdge() + new ImageFilterEdge(), + new ImageFilterKMeans() }; for (int i = 0; i < filters.length; i++) { diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterEdge.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterEdge.java index e2ce0dacd..9eda64874 100644 --- a/src/com/android/gallery3d/filtershow/filters/ImageFilterEdge.java +++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterEdge.java @@ -1,3 +1,19 @@ +/* + * 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.Bitmap; diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterKMeans.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterKMeans.java new file mode 100644 index 000000000..3c725ac81 --- /dev/null +++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterKMeans.java @@ -0,0 +1,57 @@ +/* + * 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.Bitmap; + +import com.android.gallery3d.R; + +public class ImageFilterKMeans extends ImageFilter { + public ImageFilterKMeans() { + mName = "KMeans"; + mMaxParameter = 20; + mMinParameter = 2; + mPreviewParameter = 4; + mDefaultParameter = 4; + mParameter = 4; + } + + native protected void nativeApplyFilter(Bitmap bitmap, int w, int h, int p); + + @Override + public int getButtonId() { + return R.id.kmeansButton; + } + + @Override + public int getTextId() { + return R.string.kmeans; + } + + @Override + public boolean isNil() { + return false; + } + + @Override + public Bitmap apply(Bitmap bitmap, float scaleFactor, boolean highQuality) { + int w = bitmap.getWidth(); + int h = bitmap.getHeight(); + int p = Math.max(mParameter, mMinParameter) % (mMaxParameter + 1); + nativeApplyFilter(bitmap, w, h, p); + return bitmap; + } +} |