ImageFilterFx.java revision 99baf61387ab1ef15bb9db5fa3b2b55591e87059
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 21import com.android.gallery3d.filtershow.editors.BasicEditor; 22import com.android.gallery3d.filtershow.editors.ImageOnlyEditor; 23 24public class ImageFilterFx extends ImageFilter { 25 private static final String TAG = "ImageFilterFx"; 26 private FilterFxRepresentation mParameters = null; 27 28 public ImageFilterFx() { 29 } 30 31 public void useRepresentation(FilterRepresentation representation) { 32 FilterFxRepresentation parameters = (FilterFxRepresentation) representation; 33 mParameters = parameters; 34 } 35 36 public FilterFxRepresentation getParameters() { 37 return mParameters; 38 } 39 40 native protected void nativeApplyFilter(Bitmap bitmap, int w, int h,Bitmap fxBitmap, int fxw, int fxh); 41 42 @Override 43 public Bitmap apply(Bitmap bitmap, float scaleFactor, int quality) { 44 if (getParameters() == null || getParameters().getFxBitmap() ==null) { 45 return bitmap; 46 } 47 48 int w = bitmap.getWidth(); 49 int h = bitmap.getHeight(); 50 51 int fxw = getParameters().getFxBitmap().getWidth(); 52 int fxh = getParameters().getFxBitmap().getHeight(); 53 54 nativeApplyFilter(bitmap, w, h, getParameters().getFxBitmap(), fxw, fxh); 55 return bitmap; 56 } 57} 58