Search in sources :

Example 16 with ImagePreset

use of com.android.gallery3d.filtershow.pipeline.ImagePreset 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 17 with ImagePreset

use of com.android.gallery3d.filtershow.pipeline.ImagePreset in project android_packages_apps_Gallery2 by LineageOS.

the class FilterShowActivity method removeFilterRepresentation.

public void removeFilterRepresentation(FilterRepresentation filterRepresentation) {
    if (filterRepresentation == null) {
        return;
    }
    ImagePreset oldPreset = MasterImage.getImage().getPreset();
    ImagePreset copy = new ImagePreset(oldPreset);
    copy.removeFilter(filterRepresentation);
    MasterImage.getImage().setPreset(copy, copy.getLastRepresentation(), true);
    if (MasterImage.getImage().getCurrentFilterRepresentation() == filterRepresentation) {
        FilterRepresentation lastRepresentation = copy.getLastRepresentation();
        MasterImage.getImage().setCurrentFilterRepresentation(lastRepresentation);
    }
}
Also used : ImagePreset(com.android.gallery3d.filtershow.pipeline.ImagePreset) FilterRepresentation(com.android.gallery3d.filtershow.filters.FilterRepresentation)

Example 18 with ImagePreset

use of com.android.gallery3d.filtershow.pipeline.ImagePreset in project android_packages_apps_Gallery2 by LineageOS.

the class FilterShowActivity method onMediaPickerResult.

public void onMediaPickerResult(Uri selImg) {
    mFilterPresetSource = new FilterPresetSource(this);
    int id = nameFilter(mFilterPresetSource, tempFilterArray);
    FilterPresetRepresentation fp = new FilterPresetRepresentation(getString(R.string.filtershow_preset_title) + id, id, id);
    fp.setSerializationName("Custom");
    fp.setUri(selImg);
    ImagePreset preset = new ImagePreset();
    preset.addFilter(fp);
    SaveOption sp = new SaveOption();
    sp._id = id;
    sp.name = "Custom" + id;
    sp.Uri = selImg.toString();
    tempFilterArray.add(sp);
    FiltersManager.getManager().addRepresentation(fp);
    mCategoryLooksAdapter.add(new Action(this, fp, Action.FULL_VIEW, true));
    useFilterRepresentation(fp);
    int pos = mCategoryLooksAdapter.getPositionOfPresentation(fp);
    if (pos != -1)
        backAndSetCustomFilterSelected(pos);
}
Also used : FilterPresetSource(com.android.gallery3d.filtershow.data.FilterPresetSource) Action(com.android.gallery3d.filtershow.category.Action) ImagePreset(com.android.gallery3d.filtershow.pipeline.ImagePreset) FilterPresetRepresentation(com.android.gallery3d.filtershow.filters.FilterPresetRepresentation) Point(android.graphics.Point) SaveOption(com.android.gallery3d.filtershow.data.FilterPresetSource.SaveOption)

Example 19 with ImagePreset

use of com.android.gallery3d.filtershow.pipeline.ImagePreset in project android_packages_apps_Gallery2 by LineageOS.

the class FilterShowActivity method updateCategories.

public void updateCategories() {
    if (mMasterImage == null) {
        return;
    }
    ImagePreset preset = mMasterImage.getPreset();
    mCategoryLooksAdapter.reflectImagePreset(preset);
    mCategoryBordersAdapter.reflectImagePreset(preset);
    mCategoryFiltersAdapter.reflectImagePreset(preset);
    if (mCategoryMakeupAdapter != null) {
        mCategoryMakeupAdapter.reflectImagePreset(preset);
    }
    mCategoryDualCamAdapter.reflectImagePreset(preset);
    mCategoryTruePortraitAdapter.reflectImagePreset(preset);
}
Also used : ImagePreset(com.android.gallery3d.filtershow.pipeline.ImagePreset)

Example 20 with ImagePreset

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

Aggregations

ImagePreset (com.android.gallery3d.filtershow.pipeline.ImagePreset)28 FilterRepresentation (com.android.gallery3d.filtershow.filters.FilterRepresentation)8 Bitmap (android.graphics.Bitmap)7 Matrix (android.graphics.Matrix)4 Point (android.graphics.Point)4 FilterUserPresetRepresentation (com.android.gallery3d.filtershow.filters.FilterUserPresetRepresentation)4 RectF (android.graphics.RectF)3 Uri (android.net.Uri)3 FilterMirrorRepresentation (com.android.gallery3d.filtershow.filters.FilterMirrorRepresentation)3 FilterRotateRepresentation (com.android.gallery3d.filtershow.filters.FilterRotateRepresentation)3 Canvas (android.graphics.Canvas)2 Paint (android.graphics.Paint)2 Rect (android.graphics.Rect)2 XMPMeta (com.adobe.xmp.XMPMeta)2 Action (com.android.gallery3d.filtershow.category.Action)2 FilterPresetSource (com.android.gallery3d.filtershow.data.FilterPresetSource)2 SaveOption (com.android.gallery3d.filtershow.data.FilterPresetSource.SaveOption)2 HistoryItem (com.android.gallery3d.filtershow.history.HistoryItem)2 GeometryHolder (com.android.gallery3d.filtershow.imageshow.GeometryMathUtils.GeometryHolder)2 MasterImage (com.android.gallery3d.filtershow.imageshow.MasterImage)2