import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.Matrix;
-import android.support.v8.renderscript.Allocation;
+import android.renderscript.Allocation;
import android.widget.Toast;
-import com.android.gallery3d.filtershow.imageshow.GeometryMetadata;
-import com.android.gallery3d.filtershow.presets.FilterEnvironment;
-import com.android.gallery3d.filtershow.presets.ImagePreset;
+import com.android.gallery3d.filtershow.imageshow.GeometryMathUtils;
+import com.android.gallery3d.filtershow.imageshow.MasterImage;
+import com.android.gallery3d.filtershow.pipeline.FilterEnvironment;
public abstract class ImageFilter implements Cloneable {
private FilterEnvironment mEnvironment = null;
public boolean supportsAllocationInput() { return false; }
public void apply(Allocation in, Allocation out) {
+ setGeneralParameters();
}
public Bitmap apply(Bitmap bitmap, float scaleFactor, int quality) {
// do nothing here, subclasses will implement filtering here
+ setGeneralParameters();
return bitmap;
}
}
protected Matrix getOriginalToScreenMatrix(int w, int h) {
- ImagePreset preset = getEnvironment().getImagePreset();
- GeometryMetadata geo = getEnvironment().getImagePreset().mGeoData;
- Matrix originalToScreen = geo.getOriginalToScreen(true,
- preset.getImageLoader().getOriginalBounds().width(),
- preset.getImageLoader().getOriginalBounds().height(),
- w, h);
- return originalToScreen;
+ return GeometryMathUtils.getImageToScreenMatrix(getEnvironment().getImagePreset()
+ .getGeometryFilters(), true, MasterImage.getImage().getOriginalBounds(), w, h);
}
public void setEnvironment(FilterEnvironment environment) {
public FilterEnvironment getEnvironment() {
return mEnvironment;
}
+
+ public void setGeneralParameters() {
+ // should implement in subclass which like to transport
+ // some information to other filters. (like the style setting from RetroLux
+ // and Film to FixedFrame)
+ mEnvironment.clearGeneralParameters();
+ }
}