Search in sources :

Example 51 with FilterRepresentation

use of com.android.gallery3d.filtershow.filters.FilterRepresentation in project android_packages_apps_Gallery2 by LineageOS.

the class ImagePreset method removeFilter.

public void removeFilter(FilterRepresentation filterRepresentation) {
    if (filterRepresentation.getFilterType() == FilterRepresentation.TYPE_BORDER || filterRepresentation.getFilterType() == FilterRepresentation.TYPE_DUALCAM || filterRepresentation.getFilterType() == FilterRepresentation.TYPE_TRUEPORTRAIT) {
        for (int i = 0; i < mFilters.size(); i++) {
            FilterRepresentation filter = mFilters.elementAt(i);
            if (filter.getFilterType() == filterRepresentation.getFilterType()) {
                mFilters.remove(i);
                // reset fusion underlay image.
                if (filter instanceof FilterDualCamFusionRepresentation || filter instanceof FilterTruePortraitFusionRepresentation) {
                    MasterImage.getImage().setFusionUnderlay(null);
                    MasterImage.getImage().setScaleFactor(1);
                    MasterImage.getImage().resetTranslation();
                }
                break;
            }
        }
    } else {
        for (int i = 0; i < mFilters.size(); i++) {
            if (sameSerializationName(mFilters.elementAt(i), filterRepresentation)) {
                mFilters.remove(i);
                break;
            }
        }
    }
}
Also used : FilterDualCamFusionRepresentation(com.android.gallery3d.filtershow.filters.FilterDualCamFusionRepresentation) FilterTruePortraitFusionRepresentation(com.android.gallery3d.filtershow.filters.FilterTruePortraitFusionRepresentation) FilterRepresentation(com.android.gallery3d.filtershow.filters.FilterRepresentation)

Example 52 with FilterRepresentation

use of com.android.gallery3d.filtershow.filters.FilterRepresentation in project android_packages_apps_Gallery2 by LineageOS.

the class ImagePreset method getUsedFilters.

public Vector<ImageFilter> getUsedFilters(BaseFiltersManager filtersManager) {
    Vector<ImageFilter> usedFilters = new Vector<ImageFilter>();
    for (int i = 0; i < mFilters.size(); i++) {
        FilterRepresentation representation = mFilters.elementAt(i);
        ImageFilter filter = filtersManager.getFilterForRepresentation(representation);
        usedFilters.add(filter);
    }
    return usedFilters;
}
Also used : ImageFilter(com.android.gallery3d.filtershow.filters.ImageFilter) FilterRepresentation(com.android.gallery3d.filtershow.filters.FilterRepresentation) Vector(java.util.Vector)

Example 53 with FilterRepresentation

use of com.android.gallery3d.filtershow.filters.FilterRepresentation in project android_packages_apps_Gallery2 by LineageOS.

the class ImagePreset method applyTruePortrait.

public Bitmap applyTruePortrait(Bitmap bitmap, FilterEnvironment environment) {
    // Returns a new bitmap.
    for (FilterRepresentation representation : mFilters) {
        if (representation.getFilterType() == FilterRepresentation.TYPE_TRUEPORTRAIT) {
            Bitmap tmp = bitmap;
            bitmap = environment.applyRepresentation(representation, bitmap);
            if (tmp != bitmap) {
                environment.cache(tmp);
            }
            if (environment.needsStop()) {
                return bitmap;
            }
        }
    }
    return bitmap;
}
Also used : Bitmap(android.graphics.Bitmap) FilterRepresentation(com.android.gallery3d.filtershow.filters.FilterRepresentation)

Example 54 with FilterRepresentation

use of com.android.gallery3d.filtershow.filters.FilterRepresentation in project android_packages_apps_Gallery2 by LineageOS.

the class ImagePreset method writeJson.

public void writeJson(JsonWriter writer, String name) {
    int numFilters = mFilters.size();
    try {
        writer.beginObject();
        for (int i = 0; i < numFilters; i++) {
            FilterRepresentation filter = mFilters.get(i);
            if (filter instanceof FilterUserPresetRepresentation) {
                continue;
            }
            String sname = filter.getSerializationName();
            if (sname == null) {
                continue;
            }
            if (DEBUG) {
                Log.v(LOGTAG, "Serialization: " + sname);
                if (sname == null) {
                    Log.v(LOGTAG, "Serialization name null for filter: " + filter);
                }
            }
            writer.name(sname);
            filter.serializeRepresentation(writer);
        }
        writer.endObject();
    } catch (IOException e) {
        Log.e(LOGTAG, "Error encoding JASON", e);
    }
}
Also used : FilterRepresentation(com.android.gallery3d.filtershow.filters.FilterRepresentation) IOException(java.io.IOException) FilterUserPresetRepresentation(com.android.gallery3d.filtershow.filters.FilterUserPresetRepresentation)

Example 55 with FilterRepresentation

use of com.android.gallery3d.filtershow.filters.FilterRepresentation in project android_packages_apps_Gallery2 by LineageOS.

the class ImagePreset method equals.

public boolean equals(ImagePreset preset) {
    if (preset == null) {
        return false;
    }
    if (preset.mFilters.size() != mFilters.size()) {
        return false;
    }
    if (mDoApplyGeometry != preset.mDoApplyGeometry) {
        return false;
    }
    if (mDoApplyFilters != preset.mDoApplyFilters) {
        if (mFilters.size() > 0 || preset.mFilters.size() > 0) {
            return false;
        }
    }
    for (int i = 0; i < preset.mFilters.size(); i++) {
        FilterRepresentation a = preset.mFilters.elementAt(i);
        FilterRepresentation b = mFilters.elementAt(i);
        boolean isGeometry = false;
        if (a instanceof FilterRotateRepresentation || a instanceof FilterMirrorRepresentation || a instanceof FilterCropRepresentation || a instanceof FilterStraightenRepresentation) {
            isGeometry = true;
        }
        boolean evaluate = true;
        if (!isGeometry && mDoApplyGeometry && !mDoApplyFilters) {
            evaluate = false;
        } else if (isGeometry && !mDoApplyGeometry && mDoApplyFilters) {
            evaluate = false;
        }
        if (evaluate && !a.equals(b)) {
            return false;
        }
    }
    return true;
}
Also used : FilterMirrorRepresentation(com.android.gallery3d.filtershow.filters.FilterMirrorRepresentation) FilterStraightenRepresentation(com.android.gallery3d.filtershow.filters.FilterStraightenRepresentation) FilterRepresentation(com.android.gallery3d.filtershow.filters.FilterRepresentation) FilterCropRepresentation(com.android.gallery3d.filtershow.filters.FilterCropRepresentation) FilterRotateRepresentation(com.android.gallery3d.filtershow.filters.FilterRotateRepresentation)

Aggregations

FilterRepresentation (com.android.gallery3d.filtershow.filters.FilterRepresentation)78 Action (com.android.gallery3d.filtershow.category.Action)12 FiltersManager (com.android.gallery3d.filtershow.filters.FiltersManager)12 CategoryAdapter (com.android.gallery3d.filtershow.category.CategoryAdapter)11 Point (android.graphics.Point)8 ImagePreset (com.android.gallery3d.filtershow.pipeline.ImagePreset)8 Bitmap (android.graphics.Bitmap)7 FilterUserPresetRepresentation (com.android.gallery3d.filtershow.filters.FilterUserPresetRepresentation)6 FilterShowActivity (com.android.gallery3d.filtershow.FilterShowActivity)5 FilterDualCamFusionRepresentation (com.android.gallery3d.filtershow.filters.FilterDualCamFusionRepresentation)5 FilterMirrorRepresentation (com.android.gallery3d.filtershow.filters.FilterMirrorRepresentation)5 MasterImage (com.android.gallery3d.filtershow.imageshow.MasterImage)5 FilterGradRepresentation (com.android.gallery3d.filtershow.filters.FilterGradRepresentation)4 FilterRotateRepresentation (com.android.gallery3d.filtershow.filters.FilterRotateRepresentation)4 ArrayList (java.util.ArrayList)4 Uri (android.net.Uri)3 LayoutInflater (android.view.LayoutInflater)3 View (android.view.View)3 OnClickListener (android.view.View.OnClickListener)3 FilterCropRepresentation (com.android.gallery3d.filtershow.filters.FilterCropRepresentation)3