diff options
| author | Ruben Brunk <rubenbrunk@google.com> | 2012-12-12 21:35:12 -0800 |
|---|---|---|
| committer | Ruben Brunk <rubenbrunk@google.com> | 2012-12-13 00:49:28 -0800 |
| commit | 27fb72ee1413871b4958ab2f24a229574de6ffa2 (patch) | |
| tree | bad70566be85c1b807ce785ad1260a5a84a321a1 /src | |
| parent | 8fd29857977e3ca763266704e2a2c35a59cb522d (diff) | |
| download | android_packages_apps_Gallery2-27fb72ee1413871b4958ab2f24a229574de6ffa2.tar.gz android_packages_apps_Gallery2-27fb72ee1413871b4958ab2f24a229574de6ffa2.tar.bz2 android_packages_apps_Gallery2-27fb72ee1413871b4958ab2f24a229574de6ffa2.zip | |
Added K-Means clustering filter.
Change-Id: If8961d4a21de953b754cf74aefc222b6bec902a3
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; + } +} |
