ImageFilterVibrance.java revision 4b1e6fbdf437b7a25fb3eb18a2ed43c9ab4eccc8
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 */ 16b559b2dd6637660ddbbdbae79a742c9f0fb1180bJohn Hoford 17b559b2dd6637660ddbbdbae79a742c9f0fb1180bJohn Hofordpackage com.android.gallery3d.filtershow.filters; 18b559b2dd6637660ddbbdbae79a742c9f0fb1180bJohn Hoford 198cc3b55d615b349b4fcdff0eeeefe6907d4950ffnicolasroardimport com.android.gallery3d.R; 208cc3b55d615b349b4fcdff0eeeefe6907d4950ffnicolasroard 21b559b2dd6637660ddbbdbae79a742c9f0fb1180bJohn Hofordimport android.graphics.Bitmap; 22b559b2dd6637660ddbbdbae79a742c9f0fb1180bJohn Hoford 2371f04cbaedbb89e313e0b86b531640db2d3f6016nicolasroardpublic class ImageFilterVibrance extends SimpleImageFilter { 24b559b2dd6637660ddbbdbae79a742c9f0fb1180bJohn Hoford 25b559b2dd6637660ddbbdbae79a742c9f0fb1180bJohn Hoford public ImageFilterVibrance() { 26b559b2dd6637660ddbbdbae79a742c9f0fb1180bJohn Hoford mName = "Vibrance"; 27b559b2dd6637660ddbbdbae79a742c9f0fb1180bJohn Hoford } 28b559b2dd6637660ddbbdbae79a742c9f0fb1180bJohn Hoford 2971f04cbaedbb89e313e0b86b531640db2d3f6016nicolasroard public FilterRepresentation getDefaultRepresentation() { 304b1e6fbdf437b7a25fb3eb18a2ed43c9ab4eccc8John Hoford FilterBasicRepresentation representation = 314b1e6fbdf437b7a25fb3eb18a2ed43c9ab4eccc8John Hoford (FilterBasicRepresentation) super.getDefaultRepresentation(); 3271f04cbaedbb89e313e0b86b531640db2d3f6016nicolasroard representation.setName("Vibrance"); 3371f04cbaedbb89e313e0b86b531640db2d3f6016nicolasroard representation.setFilterClass(ImageFilterVibrance.class); 346900cad45d240c9a54b92991538b6a33652e766cnicolasroard representation.setTextId(R.string.vibrance); 356900cad45d240c9a54b92991538b6a33652e766cnicolasroard representation.setButtonId(R.id.vibranceButton); 364b1e6fbdf437b7a25fb3eb18a2ed43c9ab4eccc8John Hoford representation.setMinimum(-100); 374b1e6fbdf437b7a25fb3eb18a2ed43c9ab4eccc8John Hoford representation.setMaximum(100); 384b1e6fbdf437b7a25fb3eb18a2ed43c9ab4eccc8John Hoford representation.setDefaultValue(0); 3971f04cbaedbb89e313e0b86b531640db2d3f6016nicolasroard return representation; 4071f04cbaedbb89e313e0b86b531640db2d3f6016nicolasroard } 4171f04cbaedbb89e313e0b86b531640db2d3f6016nicolasroard 42b559b2dd6637660ddbbdbae79a742c9f0fb1180bJohn Hoford native protected void nativeApplyFilter(Bitmap bitmap, int w, int h, float bright); 43b559b2dd6637660ddbbdbae79a742c9f0fb1180bJohn Hoford 44b559b2dd6637660ddbbdbae79a742c9f0fb1180bJohn Hoford @Override 4599baf61387ab1ef15bb9db5fa3b2b55591e87059John Hoford public Bitmap apply(Bitmap bitmap, float scaleFactor, int quality) { 4671f04cbaedbb89e313e0b86b531640db2d3f6016nicolasroard if (getParameters() == null) { 4771f04cbaedbb89e313e0b86b531640db2d3f6016nicolasroard return bitmap; 4871f04cbaedbb89e313e0b86b531640db2d3f6016nicolasroard } 49b559b2dd6637660ddbbdbae79a742c9f0fb1180bJohn Hoford int w = bitmap.getWidth(); 50b559b2dd6637660ddbbdbae79a742c9f0fb1180bJohn Hoford int h = bitmap.getHeight(); 5171f04cbaedbb89e313e0b86b531640db2d3f6016nicolasroard float value = getParameters().getValue(); 52b559b2dd6637660ddbbdbae79a742c9f0fb1180bJohn Hoford nativeApplyFilter(bitmap, w, h, value); 5381eb9976f967d9b3faa1749a8ab29d1743cf347dnicolasroard 5481eb9976f967d9b3faa1749a8ab29d1743cf347dnicolasroard return bitmap; 55b559b2dd6637660ddbbdbae79a742c9f0fb1180bJohn Hoford } 56b559b2dd6637660ddbbdbae79a742c9f0fb1180bJohn Hoford} 57