what-the-bank/sources/o/tDU.java

111 lines
4.3 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package o;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import java.io.ByteArrayOutputStream;
import java.io.OutputStream;
/* loaded from: classes.dex */
public final class tDU implements utG {
private final int a;
private final String b;
private final Bitmap.CompressFormat c;
public tDU(int i) {
String str;
Bitmap.CompressFormat compressFormat;
this.a = i;
if (i != 1) {
str = i != 3 ? "jpeg" : "webp";
} else {
str = "png";
}
this.b = str;
if (i == 1) {
compressFormat = Bitmap.CompressFormat.PNG;
} else if (i == 3) {
compressFormat = Bitmap.CompressFormat.WEBP;
} else {
compressFormat = Bitmap.CompressFormat.JPEG;
}
this.c = compressFormat;
}
@Override // o.utG
public final void d(Context context, String str, OutputStream outputStream, int i, int i2, int i3, int i4, boolean z, int i5, int i6) {
int i7 = i5;
int i8 = i6;
while (true) {
C14957gcv.e(context, "");
C14957gcv.e(str, "");
C14957gcv.e(outputStream, "");
if (i8 <= 0) {
return;
}
try {
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = false;
options.inPreferredConfig = Bitmap.Config.RGB_565;
options.inSampleSize = i7;
Bitmap decodeFile = BitmapFactory.decodeFile(str, options);
C14957gcv.c(decodeFile, "");
byte[] Gj_ = C9362diM.Gj_(decodeFile, i, i2, i3, i4, this.a);
if (z && this.c == Bitmap.CompressFormat.JPEG) {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
byteArrayOutputStream.write(Gj_);
outputStream.write(new DYW(str).c(context, byteArrayOutputStream).toByteArray());
return;
}
outputStream.write(Gj_);
return;
} catch (OutOfMemoryError unused) {
System.gc();
i7 <<= 1;
i8--;
}
}
}
@Override // o.utG
public final void d(Context context, byte[] bArr, OutputStream outputStream, int i, int i2, int i3, int i4, boolean z, int i5) {
C14957gcv.e(context, "");
C14957gcv.e(bArr, "");
C14957gcv.e(outputStream, "");
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = false;
options.inPreferredConfig = Bitmap.Config.RGB_565;
options.inSampleSize = i5;
Bitmap decodeByteArray = BitmapFactory.decodeByteArray(bArr, 0, bArr.length, options);
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
float width = decodeByteArray.getWidth();
float height = decodeByteArray.getHeight();
C7280clM.c("src width = ".concat(String.valueOf(width)));
C7280clM.c("src height = ".concat(String.valueOf(height)));
C14957gcv.c(decodeByteArray, "");
float Gh_ = C9362diM.Gh_(decodeByteArray, i, i2);
C7280clM.c("scale = ".concat(String.valueOf(Gh_)));
float f = width / Gh_;
float f2 = height / Gh_;
C7280clM.c("dst width = ".concat(String.valueOf(f)));
C7280clM.c("dst height = ".concat(String.valueOf(f2)));
Bitmap createScaledBitmap = Bitmap.createScaledBitmap(decodeByteArray, (int) f, (int) f2, true);
C14957gcv.c(createScaledBitmap, "");
C9362diM.Gl_(createScaledBitmap, i4).compress(this.c, i3, byteArrayOutputStream);
byte[] byteArray = byteArrayOutputStream.toByteArray();
C14957gcv.c(byteArray, "");
if (z && this.c == Bitmap.CompressFormat.JPEG) {
ByteArrayOutputStream byteArrayOutputStream2 = new ByteArrayOutputStream();
byteArrayOutputStream2.write(byteArray);
outputStream.write(new DYW(bArr).c(context, byteArrayOutputStream2).toByteArray());
return;
}
outputStream.write(byteArray);
}
@Override // o.utG
public final int b() {
return this.a;
}
}