Search in sources :

Example 1 with FaceBlurRenderer

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();
        }
    }
}
Also used : EditorElement(org.signal.imageeditor.core.model.EditorElement) FaceBlurRenderer(org.signal.imageeditor.core.renderers.FaceBlurRenderer)

Example 2 with FaceBlurRenderer

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);
}
Also used : Matrix(android.graphics.Matrix) SelectableRenderer(org.signal.imageeditor.core.SelectableRenderer) Renderer(org.signal.imageeditor.core.Renderer) ColorableRenderer(org.signal.imageeditor.core.ColorableRenderer) BezierDrawingRenderer(org.signal.imageeditor.core.renderers.BezierDrawingRenderer) MultiLineTextRenderer(org.signal.imageeditor.core.renderers.MultiLineTextRenderer) FaceBlurRenderer(org.signal.imageeditor.core.renderers.FaceBlurRenderer) EditorElement(org.signal.imageeditor.core.model.EditorElement) FaceBlurRenderer(org.signal.imageeditor.core.renderers.FaceBlurRenderer)

Example 3 with FaceBlurRenderer

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);
            }
        }
    }
}
Also used : FaceBlurRenderer(org.signal.imageeditor.core.renderers.FaceBlurRenderer) Point(android.graphics.Point)

Aggregations

FaceBlurRenderer (org.signal.imageeditor.core.renderers.FaceBlurRenderer)3 EditorElement (org.signal.imageeditor.core.model.EditorElement)2 Matrix (android.graphics.Matrix)1 Point (android.graphics.Point)1 ColorableRenderer (org.signal.imageeditor.core.ColorableRenderer)1 Renderer (org.signal.imageeditor.core.Renderer)1 SelectableRenderer (org.signal.imageeditor.core.SelectableRenderer)1 BezierDrawingRenderer (org.signal.imageeditor.core.renderers.BezierDrawingRenderer)1 MultiLineTextRenderer (org.signal.imageeditor.core.renderers.MultiLineTextRenderer)1