ImageFilterFx.java revision 71f04cbaedbb89e313e0b86b531640db2d3f6016
1/* 2 * Copyright (C) 2012 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17package com.android.gallery3d.filtershow.filters; 18 19import android.graphics.Bitmap; 20 21public class ImageFilterFx extends ImageFilter { 22 private static final String TAG = "ImageFilterFx"; 23 Bitmap fxBitmap; 24 int mNameResource = 0; 25 26 public ImageFilterFx(Bitmap fxBitmap, String name, int nameResource) { 27 setFilterType(TYPE_FX); 28 mName = name; 29 this.fxBitmap = fxBitmap; 30 mNameResource = nameResource; 31 } 32 33 @Override 34 public int getTextId() { 35 return mNameResource; 36 } 37 38 @Override 39 public ImageFilter clone() throws CloneNotSupportedException { 40 ImageFilterFx filter = (ImageFilterFx) super.clone(); 41 filter.fxBitmap = this.fxBitmap; 42 return filter; 43 } 44 45 public boolean isNil() { 46 if (fxBitmap != null) { 47 return false; 48 } 49 return true; 50 } 51 52 @Override 53 public boolean showParameterValue() { 54 return false; 55 } 56 57 @Override 58 public boolean showEditingControls() { 59 return false; 60 } 61 62 @Override 63 public boolean showUtilityPanel() { 64 return false; 65 } 66 67 native protected void nativeApplyFilter(Bitmap bitmap, int w, int h,Bitmap fxBitmap, int fxw, int fxh); 68 69 @Override 70 public Bitmap apply(Bitmap bitmap, float scaleFactor, boolean highQuality) { 71 if (fxBitmap==null) 72 return bitmap; 73 74 int w = bitmap.getWidth(); 75 int h = bitmap.getHeight(); 76 77 int fxw = fxBitmap.getWidth(); 78 int fxh = fxBitmap.getHeight(); 79 80 nativeApplyFilter(bitmap, w, h, fxBitmap, fxw, fxh); 81 return bitmap; 82 } 83} 84