use of org.signal.imageeditor.core.Renderer 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.Renderer in project Signal-Android by WhisperSystems.
the class ImageEditorFragment method changeEntityColor.
private void changeEntityColor(int selectedColor) {
if (currentSelection != null) {
Renderer renderer = currentSelection.getRenderer();
if (renderer instanceof ColorableRenderer) {
((ColorableRenderer) renderer).setColor(selectedColor);
onDrawingChanged(false, true);
}
}
}
use of org.signal.imageeditor.core.Renderer in project Signal-Android by WhisperSystems.
the class EditorModel method getUniqueColorsIgnoringAlpha.
public Set<Integer> getUniqueColorsIgnoringAlpha() {
final Set<Integer> colors = new LinkedHashSet<>();
editorElementHierarchy.getRoot().forAllInTree(element -> {
Renderer renderer = element.getRenderer();
if (renderer instanceof ColorableRenderer) {
colors.add(((ColorableRenderer) renderer).getColor() | 0xff000000);
}
});
return colors;
}
use of org.signal.imageeditor.core.Renderer in project Signal-Android by WhisperSystems.
the class EditorModel method isRendererOfMainImage.
private boolean isRendererOfMainImage(@NonNull Renderer renderer) {
EditorElement mainImage = editorElementHierarchy.getMainImage();
Renderer mainImageRenderer = mainImage != null ? mainImage.getRenderer() : null;
return mainImageRenderer == renderer;
}
use of org.signal.imageeditor.core.Renderer in project Signal-Android by WhisperSystems.
the class EditorElement method findElementAt.
EditorElement findElementAt(float x, float y, @NonNull Matrix viewModelMatrix, @NonNull Matrix outInverseModelMatrix) {
final float[] dst = new float[2];
final float[] src = { x, y };
return findElement(viewModelMatrix, outInverseModelMatrix, (element, inverseMatrix) -> {
Renderer renderer = element.renderer;
if (renderer == null)
return false;
inverseMatrix.mapPoints(dst, src);
return element.flags.isSelectable() && renderer.hitTest(dst[0], dst[1]);
});
}
Aggregations