Search in sources :

Example 1 with UriGlideRenderer

use of org.thoughtcrime.securesms.scribbles.UriGlideRenderer in project Signal-Android by WhisperSystems.

the class WallpaperCropActivity method setupImageEditor.

private void setupImageEditor(@NonNull Uri imageUri) {
    DisplayMetrics displayMetrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
    int height = displayMetrics.heightPixels;
    int width = displayMetrics.widthPixels;
    float ratio = width / (float) height;
    EditorModel editorModel = EditorModel.createForWallpaperEditing(ratio);
    EditorElement image = new EditorElement(new UriGlideRenderer(imageUri, true, width, height, UriGlideRenderer.WEAK_BLUR));
    image.getFlags().setSelectable(false).persist();
    editorModel.addElement(image);
    imageEditor.setModel(editorModel);
    imageEditor.setSizeChangedListener((newWidth, newHeight) -> {
        float newRatio = newWidth / (float) newHeight;
        Log.i(TAG, String.format(Locale.US, "Output size (%d, %d) (ratio %.2f)", newWidth, newHeight, newRatio));
        editorModel.setFixedRatio(newRatio);
    });
}
Also used : UriGlideRenderer(org.thoughtcrime.securesms.scribbles.UriGlideRenderer) EditorModel(org.signal.imageeditor.core.model.EditorModel) EditorElement(org.signal.imageeditor.core.model.EditorElement) DisplayMetrics(android.util.DisplayMetrics) Point(android.graphics.Point)

Aggregations

Point (android.graphics.Point)1 DisplayMetrics (android.util.DisplayMetrics)1 EditorElement (org.signal.imageeditor.core.model.EditorElement)1 EditorModel (org.signal.imageeditor.core.model.EditorModel)1 UriGlideRenderer (org.thoughtcrime.securesms.scribbles.UriGlideRenderer)1