Search in sources :

Example 36 with FilterRepresentation

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

the class ImagePreset method applyFilters.

public Bitmap applyFilters(Bitmap bitmap, int from, int to, FilterEnvironment environment) {
    if (mDoApplyFilters) {
        if (from < 0) {
            from = 0;
        }
        if (to == -1) {
            to = mFilters.size();
        }
        for (int i = from; i < to; i++) {
            FilterRepresentation representation = mFilters.elementAt(i);
            if (representation.getFilterType() == FilterRepresentation.TYPE_GEOMETRY) {
                // skip the geometry as it's already applied.
                continue;
            }
            if (representation.getFilterType() == FilterRepresentation.TYPE_BORDER) {
                // TODO: might be worth getting rid of applyBorder.
                continue;
            }
            if (representation.getFilterType() == FilterRepresentation.TYPE_DUALCAM) {
                // skip the dual cam as it's already applied.
                continue;
            }
            if (representation.getFilterType() == FilterRepresentation.TYPE_TRUEPORTRAIT) {
                // skip the true portrait as it's already applied.
                continue;
            }
            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 37 with FilterRepresentation

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

the class ImagePreset method applyDualCamera.

public Bitmap applyDualCamera(Bitmap bitmap, FilterEnvironment environment) {
    // Returns a new bitmap.
    for (FilterRepresentation representation : mFilters) {
        if (representation.getFilterType() == FilterRepresentation.TYPE_DUALCAM) {
            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 38 with FilterRepresentation

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

the class StateView method onTouchEvent.

@Override
public boolean onTouchEvent(MotionEvent event) {
    boolean ret = super.onTouchEvent(event);
    FilterShowActivity activity = (FilterShowActivity) getContext();
    if (event.getActionMasked() == MotionEvent.ACTION_UP) {
        activity.startTouchAnimation(this, event.getX(), event.getY());
    }
    if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
        mStartTouchY = event.getY();
        mStartTouchX = event.getX();
        if (mType == BEGIN) {
            MasterImage.getImage().setShowsOriginal(true);
        }
    }
    if (event.getActionMasked() == MotionEvent.ACTION_UP || event.getActionMasked() == MotionEvent.ACTION_CANCEL) {
        setTranslationX(0);
        setTranslationY(0);
        MasterImage.getImage().setShowsOriginal(false);
        if (mType != BEGIN && event.getActionMasked() == MotionEvent.ACTION_UP) {
            setSelected(true);
            FilterRepresentation representation = getState().getFilterRepresentation();
            MasterImage image = MasterImage.getImage();
            ImagePreset preset = image != null ? image.getCurrentPreset() : null;
            if (getTranslationY() == 0 && image != null && preset != null && representation != image.getCurrentFilterRepresentation() && preset.getRepresentation(representation) != null) {
                activity.showRepresentation(representation);
                setSelected(false);
            }
        }
    }
    if (mType != BEGIN && event.getActionMasked() == MotionEvent.ACTION_MOVE) {
        float delta = event.getY() - mStartTouchY;
        if (Math.abs(delta) > mDeleteSlope) {
            activity.setHandlesSwipeForView(this, mStartTouchX, mStartTouchY);
        }
    }
    return true;
}
Also used : MasterImage(com.android.gallery3d.filtershow.imageshow.MasterImage) ImagePreset(com.android.gallery3d.filtershow.pipeline.ImagePreset) FilterShowActivity(com.android.gallery3d.filtershow.FilterShowActivity) FilterRepresentation(com.android.gallery3d.filtershow.filters.FilterRepresentation)

Example 39 with FilterRepresentation

use of com.android.gallery3d.filtershow.filters.FilterRepresentation 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 40 with FilterRepresentation

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

the class FilterShowActivity method fillLooks.

private void fillLooks() {
    FiltersManager filtersManager = FiltersManager.getManager();
    ArrayList<FilterRepresentation> filtersRepresentations = filtersManager.getLooks();
    if (mCategoryLooksAdapter != null) {
        mCategoryLooksAdapter.clear();
    }
    mCategoryLooksAdapter = new CategoryAdapter(this);
    int verticalItemHeight = (int) getResources().getDimension(R.dimen.action_item_height);
    mCategoryLooksAdapter.setItemHeight(verticalItemHeight);
    for (FilterRepresentation representation : filtersRepresentations) {
        mCategoryLooksAdapter.add(new Action(this, representation, Action.FULL_VIEW));
    }
    if (FilterGeneratorNativeEngine.getInstance().isLibLoaded()) {
        if (mUserPresetsManager.getRepresentations() == null || mUserPresetsManager.getRepresentations().size() == 0) {
            mCategoryLooksAdapter.add(new Action(this, Action.ADD_ACTION));
        }
    }
    fillPresetFilter();
    Fragment panel = getSupportFragmentManager().findFragmentByTag(MainPanel.FRAGMENT_TAG);
    if (panel != null) {
        if (panel instanceof MainPanel) {
            MainPanel mainPanel = (MainPanel) panel;
            mainPanel.loadCategoryLookPanel(true);
        }
    }
}
Also used : Action(com.android.gallery3d.filtershow.category.Action) FiltersManager(com.android.gallery3d.filtershow.filters.FiltersManager) MainPanel(com.android.gallery3d.filtershow.category.MainPanel) CategoryAdapter(com.android.gallery3d.filtershow.category.CategoryAdapter) FilterRepresentation(com.android.gallery3d.filtershow.filters.FilterRepresentation) Fragment(android.support.v4.app.Fragment) MediaPickerFragment(com.android.gallery3d.filtershow.mediapicker.MediaPickerFragment) DialogFragment(android.support.v4.app.DialogFragment) Point(android.graphics.Point)

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