mirror of
https://github.com/oxen-io/session-android.git
synced 2023-12-14 02:53:01 +01:00
33 lines
1 KiB
Java
33 lines
1 KiB
Java
package org.thoughtcrime.securesms.mediasend;
|
|
|
|
import android.graphics.Bitmap;
|
|
import android.graphics.Canvas;
|
|
import android.graphics.Matrix;
|
|
import android.support.annotation.NonNull;
|
|
|
|
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
|
|
import com.bumptech.glide.load.resource.bitmap.BitmapTransformation;
|
|
|
|
import java.security.MessageDigest;
|
|
|
|
public class FlipTransformation extends BitmapTransformation {
|
|
|
|
@Override
|
|
protected Bitmap transform(@NonNull BitmapPool pool, @NonNull Bitmap toTransform, int outWidth, int outHeight) {
|
|
Bitmap output = pool.get(toTransform.getWidth(), toTransform.getHeight(), toTransform.getConfig());
|
|
|
|
Canvas canvas = new Canvas(output);
|
|
Matrix matrix = new Matrix();
|
|
matrix.setScale(-1, 1);
|
|
matrix.postTranslate(toTransform.getWidth(), 0);
|
|
|
|
canvas.drawBitmap(toTransform, matrix, null);
|
|
|
|
return output;
|
|
}
|
|
|
|
@Override
|
|
public void updateDiskCacheKey(@NonNull MessageDigest messageDigest) {
|
|
messageDigest.update(FlipTransformation.class.getSimpleName().getBytes());
|
|
}
|
|
}
|