use of org.signal.imageeditor.core.model.EditorElement in project Signal-Android by WhisperSystems.
the class UriGlideRenderer method renderBlurOverlay.
private void renderBlurOverlay(RendererContext rendererContext) {
boolean renderMask = false;
for (EditorElement child : rendererContext.getChildren()) {
if (child.getZOrder() == EditorModel.Z_MASK) {
renderMask = true;
if (blurPaint == null) {
blurPaint = new Paint();
blurPaint.setAntiAlias(true);
blurPaint.setFilterBitmap(true);
blurPaint.setDither(true);
}
blurPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_OUT));
rendererContext.setMaskPaint(blurPaint);
child.draw(rendererContext);
}
}
if (renderMask) {
rendererContext.save();
rendererContext.canvasMatrix.concat(imageProjectionMatrix);
blurPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_ATOP));
blurPaint.setMaskFilter(null);
if (blurredBitmap == null) {
blurredBitmap = blur(bitmap, rendererContext.context, blurRadius);
blurScaleMatrix.setRectToRect(new RectF(0, 0, blurredBitmap.getWidth(), blurredBitmap.getHeight()), new RectF(0, 0, bitmap.getWidth(), bitmap.getHeight()), Matrix.ScaleToFit.FILL);
}
rendererContext.canvas.concat(blurScaleMatrix);
rendererContext.canvas.drawBitmap(blurredBitmap, 0, 0, blurPaint);
blurPaint.setXfermode(null);
rendererContext.restore();
}
}
use of org.signal.imageeditor.core.model.EditorElement in project Signal-Android by signalapp.
the class ImageEditorView method startADrawingSession.
private EditSession startADrawingSession(@NonNull PointF point) {
BezierDrawingRenderer renderer = new BezierDrawingRenderer(color, thickness * Bounds.FULL_BOUNDS.width(), cap, model.findCropRelativeToRoot());
EditorElement element = new EditorElement(renderer, mode == Mode.Blur ? EditorModel.Z_MASK : EditorModel.Z_DRAWING);
model.addElementCentered(element, 1);
Matrix elementInverseMatrix = model.findElementInverseMatrix(element, viewMatrix);
return DrawingSession.start(element, renderer, elementInverseMatrix, point);
}
use of org.signal.imageeditor.core.model.EditorElement in project Signal-Android by signalapp.
the class ImageEditorView method startAMoveAndResizeSession.
private EditSession startAMoveAndResizeSession(@NonNull Matrix inverse, @NonNull PointF point, @Nullable EditorElement selected) {
Matrix elementInverseMatrix;
if (selected == null)
return null;
if (selected.getRenderer() instanceof ThumbRenderer) {
ThumbRenderer thumb = (ThumbRenderer) selected.getRenderer();
EditorElement thumbControlledElement = getModel().findById(thumb.getElementToControl());
if (thumbControlledElement == null)
return null;
EditorElement thumbsParent = getModel().getRoot().findParent(selected);
if (thumbsParent == null)
return null;
Matrix thumbContainerRelativeMatrix = model.findRelativeMatrix(thumbsParent, thumbControlledElement);
if (thumbContainerRelativeMatrix == null)
return null;
selected = thumbControlledElement;
elementInverseMatrix = model.findElementInverseMatrix(selected, viewMatrix);
if (elementInverseMatrix != null) {
return ThumbDragEditSession.startDrag(selected, elementInverseMatrix, thumbContainerRelativeMatrix, thumb.getControlPoint(), point);
} else {
return null;
}
}
return ElementDragEditSession.startDrag(selected, inverse, point);
}
use of org.signal.imageeditor.core.model.EditorElement in project Signal-Android by signalapp.
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();
}
}
}
Aggregations