use of com.android.gallery3d.filtershow.filters.FilterRepresentation in project android_packages_apps_Gallery2 by LineageOS.
the class ImagePreset method removeFilter.
public void removeFilter(FilterRepresentation filterRepresentation) {
if (filterRepresentation.getFilterType() == FilterRepresentation.TYPE_BORDER || filterRepresentation.getFilterType() == FilterRepresentation.TYPE_DUALCAM || filterRepresentation.getFilterType() == FilterRepresentation.TYPE_TRUEPORTRAIT) {
for (int i = 0; i < mFilters.size(); i++) {
FilterRepresentation filter = mFilters.elementAt(i);
if (filter.getFilterType() == filterRepresentation.getFilterType()) {
mFilters.remove(i);
// reset fusion underlay image.
if (filter instanceof FilterDualCamFusionRepresentation || filter instanceof FilterTruePortraitFusionRepresentation) {
MasterImage.getImage().setFusionUnderlay(null);
MasterImage.getImage().setScaleFactor(1);
MasterImage.getImage().resetTranslation();
}
break;
}
}
} else {
for (int i = 0; i < mFilters.size(); i++) {
if (sameSerializationName(mFilters.elementAt(i), filterRepresentation)) {
mFilters.remove(i);
break;
}
}
}
}
use of com.android.gallery3d.filtershow.filters.FilterRepresentation in project android_packages_apps_Gallery2 by LineageOS.
the class ImagePreset method getUsedFilters.
public Vector<ImageFilter> getUsedFilters(BaseFiltersManager filtersManager) {
Vector<ImageFilter> usedFilters = new Vector<ImageFilter>();
for (int i = 0; i < mFilters.size(); i++) {
FilterRepresentation representation = mFilters.elementAt(i);
ImageFilter filter = filtersManager.getFilterForRepresentation(representation);
usedFilters.add(filter);
}
return usedFilters;
}
use of com.android.gallery3d.filtershow.filters.FilterRepresentation in project android_packages_apps_Gallery2 by LineageOS.
the class ImagePreset method applyTruePortrait.
public Bitmap applyTruePortrait(Bitmap bitmap, FilterEnvironment environment) {
// Returns a new bitmap.
for (FilterRepresentation representation : mFilters) {
if (representation.getFilterType() == FilterRepresentation.TYPE_TRUEPORTRAIT) {
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 writeJson.
public void writeJson(JsonWriter writer, String name) {
int numFilters = mFilters.size();
try {
writer.beginObject();
for (int i = 0; i < numFilters; i++) {
FilterRepresentation filter = mFilters.get(i);
if (filter instanceof FilterUserPresetRepresentation) {
continue;
}
String sname = filter.getSerializationName();
if (sname == null) {
continue;
}
if (DEBUG) {
Log.v(LOGTAG, "Serialization: " + sname);
if (sname == null) {
Log.v(LOGTAG, "Serialization name null for filter: " + filter);
}
}
writer.name(sname);
filter.serializeRepresentation(writer);
}
writer.endObject();
} catch (IOException e) {
Log.e(LOGTAG, "Error encoding JASON", e);
}
}
use of com.android.gallery3d.filtershow.filters.FilterRepresentation 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;
}
Aggregations