Search in sources :

Example 1 with FilterRotateRepresentation

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

the class FilterShowActivity method showRepresentation.

public void showRepresentation(FilterRepresentation representation) {
    if (representation == null) {
        return;
    }
    Fragment currentPanel = getSupportFragmentManager().findFragmentByTag(MainPanel.FRAGMENT_TAG);
    if (currentPanel instanceof MainPanel && ((MainPanel) currentPanel).hasEditorPanel()) {
        if (representation.equals(MasterImage.getImage().getCurrentFilterRepresentation())) {
            return;
        }
        // cancel previous filter.
        cancelCurrentFilter();
        showDefaultImageView();
        removeSeekBarPanel();
    }
    if (representation instanceof FilterRotateRepresentation) {
        FilterRotateRepresentation r = (FilterRotateRepresentation) representation;
        r.rotateCW();
    }
    if (representation instanceof FilterMirrorRepresentation) {
        FilterMirrorRepresentation r = (FilterMirrorRepresentation) representation;
        r.cycle();
    }
    if (representation.isBooleanFilter()) {
        ImagePreset preset = MasterImage.getImage().getPreset();
        if (preset.getRepresentation(representation) != null) {
            // remove
            ImagePreset copy = new ImagePreset(preset);
            copy.removeFilter(representation);
            FilterRepresentation filterRepresentation = representation.copy();
            MasterImage.getImage().setPreset(copy, filterRepresentation, true);
            MasterImage.getImage().setCurrentFilterRepresentation(null);
            setActionBar();
            showActionBar(true);
            return;
        }
    }
    if (representation.getFilterType() == FilterRepresentation.TYPE_DUALCAM) {
        DisplayMetrics dm = getResources().getDisplayMetrics();
        float[] mTmpPoint = new float[2];
        mTmpPoint[0] = dm.widthPixels / 2;
        mTmpPoint[1] = dm.heightPixels / 2;
        Matrix m = MasterImage.getImage().getScreenToImageMatrix(true);
        m.mapPoints(mTmpPoint);
        if (representation instanceof FilterDualCamBasicRepresentation) {
            ((FilterDualCamBasicRepresentation) representation).setPoint((int) mTmpPoint[0], (int) mTmpPoint[1]);
        }
        if (representation instanceof FilterDualCamFusionRepresentation) {
            ((FilterDualCamFusionRepresentation) representation).setPoint((int) mTmpPoint[0], (int) mTmpPoint[1]);
        }
    }
    if (representation.getFilterType() == FilterRepresentation.TYPE_WATERMARK) {
        if (MasterImage.getImage().getCurrentFilterRepresentation() != null && representation.getSerializationName().equals(MasterImage.getImage().getCurrentFilterRepresentation().getSerializationName())) {
            return;
        }
        showWaterMark(representation);
    }
    if (TrueScannerActs.SERIALIZATION_NAME.equals(representation.getSerializationName())) {
        Bitmap b = MasterImage.getImage().getOriginalBitmapHighres();
        int w = b.getWidth();
        int h = b.getHeight();
        if (w < h) {
            w = h;
            h = b.getWidth();
        }
        if (w <= TrueScannerActs.MIN_WIDTH || h <= TrueScannerActs.MIN_HEIGHT) {
            Toast.makeText(this, getString(R.string.image_size_too_small), Toast.LENGTH_SHORT).show();
            return;
        }
    }
    useFilterRepresentation(representation);
    loadEditorPanel(representation);
}
Also used : FilterMirrorRepresentation(com.android.gallery3d.filtershow.filters.FilterMirrorRepresentation) FilterDualCamFusionRepresentation(com.android.gallery3d.filtershow.filters.FilterDualCamFusionRepresentation) ImagePreset(com.android.gallery3d.filtershow.pipeline.ImagePreset) 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) DisplayMetrics(android.util.DisplayMetrics) FilterDualCamBasicRepresentation(com.android.gallery3d.filtershow.filters.FilterDualCamBasicRepresentation) Point(android.graphics.Point) Bitmap(android.graphics.Bitmap) Matrix(android.graphics.Matrix) MainPanel(com.android.gallery3d.filtershow.category.MainPanel) FilterRotateRepresentation(com.android.gallery3d.filtershow.filters.FilterRotateRepresentation)

Example 2 with FilterRotateRepresentation

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

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

the class FilterShowActivity method resetHistory.

void resetHistory() {
    if (mMasterImage == null) {
        return;
    }
    HistoryManager adapter = mMasterImage.getHistory();
    adapter.reset();
    HistoryItem historyItem = adapter.getItem(0);
    ImagePreset original = null;
    original = new ImagePreset();
    FilterRepresentation rep = null;
    if (historyItem != null) {
        rep = historyItem.getFilterRepresentation();
    }
    mMasterImage.setPreset(original, rep, true);
    mMasterImage.setFusionUnderlay(null);
    mMasterImage.resetTranslation();
    mMasterImage.setScaleFactor(1);
    mMasterImage.setCurrentFilterRepresentation(null);
    ArrayList<FilterRepresentation> frList = FiltersManager.getManager().getTools();
    for (FilterRepresentation fr : frList) {
        if (fr instanceof FilterRotateRepresentation) {
            ((FilterRotateRepresentation) fr).resetRotation();
        }
    }
    showDefaultImageView();
    showSaveButtonIfNeed();
    invalidateViews();
}
Also used : HistoryManager(com.android.gallery3d.filtershow.history.HistoryManager) HistoryItem(com.android.gallery3d.filtershow.history.HistoryItem) ImagePreset(com.android.gallery3d.filtershow.pipeline.ImagePreset) FilterRepresentation(com.android.gallery3d.filtershow.filters.FilterRepresentation) FilterRotateRepresentation(com.android.gallery3d.filtershow.filters.FilterRotateRepresentation)

Example 4 with FilterRotateRepresentation

use of com.android.gallery3d.filtershow.filters.FilterRotateRepresentation 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)

Example 5 with FilterRotateRepresentation

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

the class EditorRotate method reflectCurrentFilter.

@Override
public void reflectCurrentFilter() {
    MasterImage master = MasterImage.getImage();
    master.setCurrentFilterRepresentation(master.getPreset().getFilterWithSerializationName(FilterRotateRepresentation.SERIALIZATION_NAME));
    super.reflectCurrentFilter();
    FilterRepresentation rep = getLocalRepresentation();
    if (rep == null || rep instanceof FilterRotateRepresentation) {
        mImageRotate.setFilterRotateRepresentation((FilterRotateRepresentation) rep);
    } else {
        Log.w(TAG, "Could not reflect current filter, not of type: " + FilterRotateRepresentation.class.getSimpleName());
    }
    mImageRotate.invalidate();
}
Also used : MasterImage(com.android.gallery3d.filtershow.imageshow.MasterImage) FilterRepresentation(com.android.gallery3d.filtershow.filters.FilterRepresentation) FilterRotateRepresentation(com.android.gallery3d.filtershow.filters.FilterRotateRepresentation)

Aggregations

FilterRepresentation (com.android.gallery3d.filtershow.filters.FilterRepresentation)5 FilterRotateRepresentation (com.android.gallery3d.filtershow.filters.FilterRotateRepresentation)5 FilterMirrorRepresentation (com.android.gallery3d.filtershow.filters.FilterMirrorRepresentation)3 ImagePreset (com.android.gallery3d.filtershow.pipeline.ImagePreset)3 Bitmap (android.graphics.Bitmap)1 Matrix (android.graphics.Matrix)1 Point (android.graphics.Point)1 DialogFragment (android.support.v4.app.DialogFragment)1 Fragment (android.support.v4.app.Fragment)1 DisplayMetrics (android.util.DisplayMetrics)1 MainPanel (com.android.gallery3d.filtershow.category.MainPanel)1 FilterCropRepresentation (com.android.gallery3d.filtershow.filters.FilterCropRepresentation)1 FilterDualCamBasicRepresentation (com.android.gallery3d.filtershow.filters.FilterDualCamBasicRepresentation)1 FilterDualCamFusionRepresentation (com.android.gallery3d.filtershow.filters.FilterDualCamFusionRepresentation)1 FilterStraightenRepresentation (com.android.gallery3d.filtershow.filters.FilterStraightenRepresentation)1 FilterUserPresetRepresentation (com.android.gallery3d.filtershow.filters.FilterUserPresetRepresentation)1 HistoryItem (com.android.gallery3d.filtershow.history.HistoryItem)1 HistoryManager (com.android.gallery3d.filtershow.history.HistoryManager)1 MasterImage (com.android.gallery3d.filtershow.imageshow.MasterImage)1 MediaPickerFragment (com.android.gallery3d.filtershow.mediapicker.MediaPickerFragment)1