use of org.signal.imageeditor.core.renderers.FaceBlurRenderer in project Signal-Android by WhisperSystems.
the class WallpaperCropActivity method setBlurred.
private void setBlurred(boolean blurred) {
imageEditor.getModel().clearFaceRenderers();
if (blurred) {
EditorElement mainImage = imageEditor.getModel().getMainImage();
if (mainImage != null) {
EditorElement element = new EditorElement(new FaceBlurRenderer(), EditorModel.Z_MASK);
element.getFlags().setEditable(false).setSelectable(false).persist();
mainImage.addElement(element);
imageEditor.invalidate();
}
}
}
use of org.signal.imageeditor.core.renderers.FaceBlurRenderer in project Signal-Android by WhisperSystems.
the class ImageEditorFragment method renderFaceBlurs.
private void renderFaceBlurs(@NonNull FaceDetectionResult result) {
List<FaceDetector.Face> faces = result.faces;
if (faces.isEmpty()) {
cachedFaceDetection = null;
return;
}
imageEditorView.getModel().pushUndoPoint();
Matrix faceMatrix = new Matrix();
for (FaceDetector.Face face : faces) {
Renderer faceBlurRenderer = new FaceBlurRenderer();
EditorElement element = new EditorElement(faceBlurRenderer, EditorModel.Z_MASK);
Matrix localMatrix = element.getLocalMatrix();
faceMatrix.setRectToRect(Bounds.FULL_BOUNDS, face.getBounds(), Matrix.ScaleToFit.FILL);
localMatrix.set(result.position);
localMatrix.preConcat(faceMatrix);
element.getFlags().setEditable(false).setSelectable(false).persist();
imageEditorView.getModel().addElementWithoutPushUndo(element);
}
imageEditorView.invalidate();
cachedFaceDetection = new Pair<>(getUri(), result);
}
use of org.signal.imageeditor.core.renderers.FaceBlurRenderer in project Signal-Android by WhisperSystems.
the class EditorModel method clearFaceRenderers.
public void clearFaceRenderers() {
EditorElement mainImage = editorElementHierarchy.getMainImage();
if (mainImage != null) {
boolean hasPushedUndo = false;
for (int i = mainImage.getChildCount() - 1; i >= 0; i--) {
if (mainImage.getChild(i).getRenderer() instanceof FaceBlurRenderer) {
if (!hasPushedUndo) {
pushUndoPoint();
hasPushedUndo = true;
}
mainImage.deleteChild(mainImage.getChild(i), invalidate);
}
}
}
}
Aggregations