kopia lustrzana https://github.com/ryukoposting/Signal-Android
Resize avatars to 1024x1024.
rodzic
e6f9cb9929
commit
f875623cd0
|
@ -549,9 +549,17 @@ public final class EditorModel implements Parcelable, RendererContext.Ready {
|
|||
*/
|
||||
@WorkerThread
|
||||
public @NonNull Bitmap render(@NonNull Context context) {
|
||||
return render(context, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Blocking render of the model.
|
||||
*/
|
||||
@WorkerThread
|
||||
public @NonNull Bitmap render(@NonNull Context context, @Nullable Point size) {
|
||||
EditorElement image = editorElementHierarchy.getFlipRotate();
|
||||
RectF cropRect = editorElementHierarchy.getCropRect();
|
||||
Point outputSize = getOutputSize();
|
||||
Point outputSize = size != null ? size : getOutputSize();
|
||||
|
||||
Bitmap bitmap = Bitmap.createBitmap(outputSize.x, outputSize.y, Bitmap.Config.ARGB_8888);
|
||||
try {
|
||||
|
|
|
@ -2,6 +2,7 @@ package org.thoughtcrime.securesms.mediasend;
|
|||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Point;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.widget.Toast;
|
||||
|
@ -26,6 +27,8 @@ import java.util.Collections;
|
|||
|
||||
public class AvatarSelectionActivity extends AppCompatActivity implements CameraFragment.Controller, ImageEditorFragment.Controller, MediaPickerFolderFragment.Controller, MediaPickerItemFragment.Controller {
|
||||
|
||||
private static final Point AVATAR_DIMENSIONS = new Point(1024, 1024);
|
||||
|
||||
private static final String IMAGE_CAPTURE = "IMAGE_CAPTURE";
|
||||
private static final String IMAGE_EDITOR = "IMAGE_EDITOR";
|
||||
private static final String ARG_GALLERY = "ARG_GALLERY";
|
||||
|
@ -199,9 +202,6 @@ public class AvatarSelectionActivity extends AppCompatActivity implements Camera
|
|||
}
|
||||
|
||||
ImageEditorFragment.Data data = (ImageEditorFragment.Data) fragment.saveState();
|
||||
if (data == null) {
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
EditorModel model = data.readModel();
|
||||
if (model == null) {
|
||||
|
@ -210,7 +210,7 @@ public class AvatarSelectionActivity extends AppCompatActivity implements Camera
|
|||
|
||||
MediaRepository.transformMedia(this,
|
||||
Collections.singletonList(currentMedia),
|
||||
Collections.singletonMap(currentMedia, new ImageEditorModelRenderMediaTransform(model)),
|
||||
Collections.singletonMap(currentMedia, new ImageEditorModelRenderMediaTransform(model, AVATAR_DIMENSIONS)),
|
||||
output -> {
|
||||
Media transformed = output.get(currentMedia);
|
||||
|
||||
|
|
|
@ -2,15 +2,18 @@ package org.thoughtcrime.securesms.mediasend;
|
|||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Point;
|
||||
import android.net.Uri;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.WorkerThread;
|
||||
|
||||
import org.thoughtcrime.securesms.imageeditor.model.EditorModel;
|
||||
import org.thoughtcrime.securesms.logging.Log;
|
||||
import org.thoughtcrime.securesms.providers.BlobProvider;
|
||||
import org.thoughtcrime.securesms.util.MediaUtil;
|
||||
import org.thoughtcrime.securesms.util.Util;
|
||||
import org.whispersystems.libsignal.util.guava.Optional;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
|
@ -20,10 +23,16 @@ public final class ImageEditorModelRenderMediaTransform implements MediaTransfor
|
|||
|
||||
private static final String TAG = Log.tag(ImageEditorModelRenderMediaTransform.class);
|
||||
|
||||
private final EditorModel modelToRender;
|
||||
@NonNull private final EditorModel modelToRender;
|
||||
@Nullable private final Point size;
|
||||
|
||||
ImageEditorModelRenderMediaTransform(@NonNull EditorModel modelToRender) {
|
||||
this(modelToRender, null);
|
||||
}
|
||||
|
||||
ImageEditorModelRenderMediaTransform(@NonNull EditorModel modelToRender, @Nullable Point size) {
|
||||
this.modelToRender = modelToRender;
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
|
@ -31,7 +40,7 @@ public final class ImageEditorModelRenderMediaTransform implements MediaTransfor
|
|||
public @NonNull Media transform(@NonNull Context context, @NonNull Media media) {
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
|
||||
Bitmap bitmap = modelToRender.render(context);
|
||||
Bitmap bitmap = modelToRender.render(context, size);
|
||||
try {
|
||||
bitmap.compress(Bitmap.CompressFormat.JPEG, 80, outputStream);
|
||||
|
||||
|
@ -46,11 +55,7 @@ public final class ImageEditorModelRenderMediaTransform implements MediaTransfor
|
|||
return media;
|
||||
} finally {
|
||||
bitmap.recycle();
|
||||
try {
|
||||
outputStream.close();
|
||||
} catch (IOException e) {
|
||||
Log.w(TAG, e);
|
||||
}
|
||||
Util.close(outputStream);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -125,8 +125,6 @@ public final class ImageEditorFragment extends Fragment implements ImageEditorHu
|
|||
|
||||
imageMaxWidth = mediaConstraints.getImageMaxWidth(requireContext());
|
||||
imageMaxHeight = mediaConstraints.getImageMaxHeight(requireContext());
|
||||
|
||||
StickerSearchRepository repository = new StickerSearchRepository(requireContext());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
|
Ładowanie…
Reference in New Issue