ImageFilterContrast.java revision 8cc3b55d615b349b4fcdff0eeeefe6907d4950ff
1a9f280f938b5fd5891c5cfe0999f8f1d4945d7a1nicolasroard/* 2a9f280f938b5fd5891c5cfe0999f8f1d4945d7a1nicolasroard * Copyright (C) 2012 The Android Open Source Project 3a9f280f938b5fd5891c5cfe0999f8f1d4945d7a1nicolasroard * 4a9f280f938b5fd5891c5cfe0999f8f1d4945d7a1nicolasroard * Licensed under the Apache License, Version 2.0 (the "License"); 5a9f280f938b5fd5891c5cfe0999f8f1d4945d7a1nicolasroard * you may not use this file except in compliance with the License. 6a9f280f938b5fd5891c5cfe0999f8f1d4945d7a1nicolasroard * You may obtain a copy of the License at 7a9f280f938b5fd5891c5cfe0999f8f1d4945d7a1nicolasroard * 8a9f280f938b5fd5891c5cfe0999f8f1d4945d7a1nicolasroard * http://www.apache.org/licenses/LICENSE-2.0 9a9f280f938b5fd5891c5cfe0999f8f1d4945d7a1nicolasroard * 10a9f280f938b5fd5891c5cfe0999f8f1d4945d7a1nicolasroard * Unless required by applicable law or agreed to in writing, software 11a9f280f938b5fd5891c5cfe0999f8f1d4945d7a1nicolasroard * distributed under the License is distributed on an "AS IS" BASIS, 12a9f280f938b5fd5891c5cfe0999f8f1d4945d7a1nicolasroard * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13a9f280f938b5fd5891c5cfe0999f8f1d4945d7a1nicolasroard * See the License for the specific language governing permissions and 14a9f280f938b5fd5891c5cfe0999f8f1d4945d7a1nicolasroard * limitations under the License. 15a9f280f938b5fd5891c5cfe0999f8f1d4945d7a1nicolasroard */ 16d42f6c69c5980110c16cd679f914c4e4e7caa29dJohn Hoford 17d42f6c69c5980110c16cd679f914c4e4e7caa29dJohn Hofordpackage com.android.gallery3d.filtershow.filters; 18d42f6c69c5980110c16cd679f914c4e4e7caa29dJohn Hoford 198cc3b55d615b349b4fcdff0eeeefe6907d4950ffnicolasroardimport com.android.gallery3d.R; 208cc3b55d615b349b4fcdff0eeeefe6907d4950ffnicolasroard 21d42f6c69c5980110c16cd679f914c4e4e7caa29dJohn Hofordimport android.graphics.Bitmap; 22d42f6c69c5980110c16cd679f914c4e4e7caa29dJohn Hoford 23d42f6c69c5980110c16cd679f914c4e4e7caa29dJohn Hofordpublic class ImageFilterContrast extends ImageFilter { 24d42f6c69c5980110c16cd679f914c4e4e7caa29dJohn Hoford 25bf93da72576b28f4e9dfb27f8f3fef702c8ae82dnicolasroard public ImageFilterContrast() { 26bf93da72576b28f4e9dfb27f8f3fef702c8ae82dnicolasroard mName = "Contrast"; 27d42f6c69c5980110c16cd679f914c4e4e7caa29dJohn Hoford } 28d42f6c69c5980110c16cd679f914c4e4e7caa29dJohn Hoford 298cc3b55d615b349b4fcdff0eeeefe6907d4950ffnicolasroard @Override 308cc3b55d615b349b4fcdff0eeeefe6907d4950ffnicolasroard public int getButtonId() { 318cc3b55d615b349b4fcdff0eeeefe6907d4950ffnicolasroard return R.id.contrastButton; 328cc3b55d615b349b4fcdff0eeeefe6907d4950ffnicolasroard } 338cc3b55d615b349b4fcdff0eeeefe6907d4950ffnicolasroard 348cc3b55d615b349b4fcdff0eeeefe6907d4950ffnicolasroard @Override 358cc3b55d615b349b4fcdff0eeeefe6907d4950ffnicolasroard public int getTextId() { 368cc3b55d615b349b4fcdff0eeeefe6907d4950ffnicolasroard return R.string.contrast; 378cc3b55d615b349b4fcdff0eeeefe6907d4950ffnicolasroard } 388cc3b55d615b349b4fcdff0eeeefe6907d4950ffnicolasroard 39d42f6c69c5980110c16cd679f914c4e4e7caa29dJohn Hoford native protected void nativeApplyFilter(Bitmap bitmap, int w, int h, float strength); 40d42f6c69c5980110c16cd679f914c4e4e7caa29dJohn Hoford 4181eb9976f967d9b3faa1749a8ab29d1743cf347dnicolasroard @Override 4281eb9976f967d9b3faa1749a8ab29d1743cf347dnicolasroard public Bitmap apply(Bitmap bitmap, float scaleFactor, boolean highQuality) { 43d42f6c69c5980110c16cd679f914c4e4e7caa29dJohn Hoford int w = bitmap.getWidth(); 44d42f6c69c5980110c16cd679f914c4e4e7caa29dJohn Hoford int h = bitmap.getHeight(); 45d42f6c69c5980110c16cd679f914c4e4e7caa29dJohn Hoford float p = mParameter; 46d42f6c69c5980110c16cd679f914c4e4e7caa29dJohn Hoford float value = p; 47d42f6c69c5980110c16cd679f914c4e4e7caa29dJohn Hoford nativeApplyFilter(bitmap, w, h, value); 4881eb9976f967d9b3faa1749a8ab29d1743cf347dnicolasroard return bitmap; 49d42f6c69c5980110c16cd679f914c4e4e7caa29dJohn Hoford } 50d42f6c69c5980110c16cd679f914c4e4e7caa29dJohn Hoford} 51