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;
}
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;
}
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;
}
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);
}
}
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);
}
}
}
Aggregations