Search in sources :

Example 6 with FilterUserPresetRepresentation

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

the class ImagePreset method fillImageStateAdapter.

public void fillImageStateAdapter(StateAdapter imageStateAdapter) {
    if (imageStateAdapter == null) {
        return;
    }
    Vector<State> states = new Vector<State>();
    for (FilterRepresentation filter : mFilters) {
        if (filter instanceof FilterUserPresetRepresentation) {
            // do not show the user preset itself in the state panel
            continue;
        }
        State state = new State(filter.getName());
        state.setFilterRepresentation(filter);
        states.add(state);
    }
    imageStateAdapter.fill(states);
}
Also used : State(com.android.gallery3d.filtershow.state.State) FilterRepresentation(com.android.gallery3d.filtershow.filters.FilterRepresentation) Vector(java.util.Vector) FilterUserPresetRepresentation(com.android.gallery3d.filtershow.filters.FilterUserPresetRepresentation)

Example 7 with FilterUserPresetRepresentation

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

the class UserPresetsAdapter method changePreset.

private void changePreset(Action action) {
    FilterRepresentation rep = action.getRepresentation();
    rep.setName(action.getName());
    if (rep instanceof FilterUserPresetRepresentation) {
        mChangedRepresentations.add((FilterUserPresetRepresentation) rep);
    }
}
Also used : FilterRepresentation(com.android.gallery3d.filtershow.filters.FilterRepresentation) FilterUserPresetRepresentation(com.android.gallery3d.filtershow.filters.FilterUserPresetRepresentation)

Example 8 with FilterUserPresetRepresentation

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

the class FilterEnvironment method applyRepresentation.

public Bitmap applyRepresentation(FilterRepresentation representation, Bitmap bitmap) {
    if (representation instanceof FilterUserPresetRepresentation) {
        // applied directly they do not themselves need to do any kind of filtering.
        return bitmap;
    }
    ImageFilter filter = mFiltersManager.getFilterForRepresentation(representation);
    if (filter == null) {
        Log.e(LOGTAG, "No ImageFilter for " + representation.getSerializationName());
        return bitmap;
    }
    filter.useRepresentation(representation);
    filter.setEnvironment(this);
    Bitmap ret = filter.apply(bitmap, mScaleFactor, mQuality);
    if (bitmap != ret) {
        cache(bitmap);
    }
    filter.setGeneralParameters();
    filter.setEnvironment(null);
    return ret;
}
Also used : Bitmap(android.graphics.Bitmap) ImageFilter(com.android.gallery3d.filtershow.filters.ImageFilter) FilterUserPresetRepresentation(com.android.gallery3d.filtershow.filters.FilterUserPresetRepresentation)

Example 9 with FilterUserPresetRepresentation

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

the class FilterShowActivity method useFilterRepresentation.

public void useFilterRepresentation(FilterRepresentation filterRepresentation) {
    if (filterRepresentation == null) {
        return;
    }
    if (!(filterRepresentation instanceof FilterRotateRepresentation) && !(filterRepresentation instanceof FilterMirrorRepresentation) && MasterImage.getImage().getCurrentFilterRepresentation() == filterRepresentation) {
        return;
    }
    if (filterRepresentation.getFilterType() == FilterWatermarkRepresentation.TYPE_WATERMARK_CATEGORY) {
        return;
    }
    boolean addToHistory = filterRepresentation.getFilterType() != FilterWatermarkRepresentation.TYPE_WATERMARK;
    if (filterRepresentation instanceof FilterUserPresetRepresentation || filterRepresentation instanceof FilterRotateRepresentation || filterRepresentation instanceof FilterMirrorRepresentation) {
        MasterImage.getImage().onNewLook(filterRepresentation);
    }
    ImagePreset oldPreset = MasterImage.getImage().getPreset();
    ImagePreset copy = new ImagePreset(oldPreset);
    FilterRepresentation representation = copy.getRepresentation(filterRepresentation);
    if (representation == null) {
        filterRepresentation = filterRepresentation.copy();
        copy.addFilter(filterRepresentation);
    } else {
        if (filterRepresentation.allowsSingleInstanceOnly()) {
            // null.
            if (!representation.equals(filterRepresentation)) {
                // Only do this if the filter isn't the same
                // (state panel clicks can lead us here)
                copy.removeFilter(representation);
                copy.addFilter(filterRepresentation);
            }
        }
    }
    MasterImage.getImage().setPreset(copy, filterRepresentation, addToHistory);
    MasterImage.getImage().setCurrentFilterRepresentation(filterRepresentation);
}
Also used : FilterMirrorRepresentation(com.android.gallery3d.filtershow.filters.FilterMirrorRepresentation) ImagePreset(com.android.gallery3d.filtershow.pipeline.ImagePreset) FilterRepresentation(com.android.gallery3d.filtershow.filters.FilterRepresentation) FilterRotateRepresentation(com.android.gallery3d.filtershow.filters.FilterRotateRepresentation) FilterUserPresetRepresentation(com.android.gallery3d.filtershow.filters.FilterUserPresetRepresentation)

Example 10 with FilterUserPresetRepresentation

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

the class FilterShowActivity method updateUserPresetsFromManager.

public void updateUserPresetsFromManager() {
    ArrayList<FilterUserPresetRepresentation> presets = mUserPresetsManager.getRepresentations();
    if (presets == null) {
        return;
    }
    if (mCategoryLooksAdapter != null) {
        fillLooks();
    }
    /*  if (presets.size() > 0) {
            mCategoryLooksAdapter.add(new Action(this, Action.SPACER));
        } */
    mUserPresetsAdapter.clear();
    if (presets.size() > 0) {
        mCategoryLooksAdapter.add(new Action(this, Action.ADD_ACTION));
    }
    for (int i = 0; i < presets.size(); i++) {
        FilterUserPresetRepresentation representation = presets.get(i);
        mCategoryLooksAdapter.add(new Action(this, representation, Action.FULL_VIEW, true));
        mUserPresetsAdapter.add(new Action(this, representation, Action.FULL_VIEW));
    }
    mCategoryLooksAdapter.notifyDataSetChanged();
    mCategoryLooksAdapter.notifyDataSetInvalidated();
}
Also used : Action(com.android.gallery3d.filtershow.category.Action) FilterUserPresetRepresentation(com.android.gallery3d.filtershow.filters.FilterUserPresetRepresentation) Point(android.graphics.Point)

Aggregations

FilterUserPresetRepresentation (com.android.gallery3d.filtershow.filters.FilterUserPresetRepresentation)14 FilterRepresentation (com.android.gallery3d.filtershow.filters.FilterRepresentation)6 ImagePreset (com.android.gallery3d.filtershow.pipeline.ImagePreset)4 Action (com.android.gallery3d.filtershow.category.Action)2 Cursor (android.database.Cursor)1 Bitmap (android.graphics.Bitmap)1 Point (android.graphics.Point)1 Message (android.os.Message)1 FilterMirrorRepresentation (com.android.gallery3d.filtershow.filters.FilterMirrorRepresentation)1 FilterRotateRepresentation (com.android.gallery3d.filtershow.filters.FilterRotateRepresentation)1 ImageFilter (com.android.gallery3d.filtershow.filters.ImageFilter)1 State (com.android.gallery3d.filtershow.state.State)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Vector (java.util.Vector)1