package p138.p145.p146.p151.p160.p161;

import android.graphics.Bitmap;
import android.util.Log;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import p138.p145.p146.p151.C2845;
import p138.p145.p146.p151.C2848;
import p138.p145.p146.p151.EnumC2842;
import p138.p145.p146.p151.InterfaceC2851;
import p138.p145.p146.p151.p152.C2855;
import p138.p145.p146.p151.p154.InterfaceC2932;
import p138.p145.p146.p151.p154.p155.InterfaceC2940;
import p138.p145.p146.p174.C3236;
import p138.p145.p146.p174.C3240;

/* JADX INFO: renamed from: ދ.ؠ.֏.ތ.ތ.ހ.ހ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes.dex */
public class C3081 implements InterfaceC2851<Bitmap> {

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public static final C2845<Integer> f9282 = C2845.m4977("com.bumptech.glide.load.resource.bitmap.BitmapEncoder.CompressionQuality", 90);

    /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
    public static final C2845<Bitmap.CompressFormat> f9283 = new C2845<>("com.bumptech.glide.load.resource.bitmap.BitmapEncoder.CompressionFormat", null, C2845.f8811);

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final InterfaceC2940 f9284;

    public C3081(InterfaceC2940 interfaceC2940) {
        this.f9284 = interfaceC2940;
    }

    @Override // p138.p145.p146.p151.InterfaceC2851
    /* JADX INFO: renamed from: ֏ */
    public EnumC2842 mo4983(C2848 c2848) {
        return EnumC2842.TRANSFORMED;
    }

    /* JADX WARN: Can't wrap try/catch for region: R(17:0|2|(2:5|(1:7)(1:8))|9|48|10|11|46|12|(5:54|13|(2:15|16)(1:17)|18|19)|52|32|33|34|(1:36)|37|(1:(0))) */
    /* JADX WARN: Removed duplicated region for block: B:36:0x0073 A[Catch: all -> 0x00c1, TRY_LEAVE, TryCatch #1 {, blocks: (B:10:0x0026, B:32:0x0069, B:34:0x006d, B:36:0x0073, B:40:0x00bd, B:41:0x00c0), top: B:48:0x0026 }] */
    @Override // p138.p145.p146.p151.InterfaceC2843
    /* JADX INFO: renamed from: ֏ */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public boolean mo4976(Object obj, File file, C2848 c2848) {
        OutputStream fileOutputStream;
        Bitmap bitmap = (Bitmap) ((InterfaceC2932) obj).get();
        Bitmap.CompressFormat compressFormat = (Bitmap.CompressFormat) c2848.m4979(f9283);
        if (compressFormat == null) {
            compressFormat = bitmap.hasAlpha() ? Bitmap.CompressFormat.PNG : Bitmap.CompressFormat.JPEG;
        }
        bitmap.getWidth();
        bitmap.getHeight();
        long jM5320 = C3236.m5320();
        int iIntValue = ((Integer) c2848.m4979(f9282)).intValue();
        boolean z = false;
        OutputStream c2855 = null;
        try {
            try {
                fileOutputStream = new FileOutputStream(file);
            } catch (IOException e) {
                e = e;
            }
        } catch (Throwable th) {
            th = th;
            fileOutputStream = c2855;
        }
        try {
            c2855 = this.f9284 != null ? new C2855(fileOutputStream, this.f9284) : fileOutputStream;
            bitmap.compress(compressFormat, iIntValue, c2855);
            c2855.close();
            z = true;
        } catch (IOException e2) {
            e = e2;
            c2855 = fileOutputStream;
            if (Log.isLoggable("BitmapEncoder", 3)) {
                Log.d("BitmapEncoder", "Failed to encode Bitmap", e);
            }
            if (c2855 != null) {
            }
            if (Log.isLoggable("BitmapEncoder", 2)) {
            }
            return z;
        } catch (Throwable th2) {
            th = th2;
            if (fileOutputStream != null) {
                try {
                    fileOutputStream.close();
                } catch (IOException unused) {
                }
            }
            throw th;
        }
        c2855.close();
        if (Log.isLoggable("BitmapEncoder", 2)) {
            Log.v("BitmapEncoder", "Compressed with type: " + compressFormat + " of size " + C3240.m5330(bitmap) + " in " + C3236.m5319(jM5320) + ", options format: " + c2848.m4979(f9283) + ", hasAlpha: " + bitmap.hasAlpha());
        }
        return z;
    }
}
