package ඓ.ῲ.K.ᕣ.ᕣ.ʬ;

import android.graphics.Bitmap;
import android.util.Log;
import com.bumptech.glide.load.EncodeStrategy;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import ඓ.ῲ.K.ᓣ.C0845;
import ඓ.ῲ.K.ᓣ.C0847;
import ඓ.ῲ.K.ᕣ.AbstractC1120;
import ඓ.ῲ.K.ᕣ.C0850;
import ඓ.ῲ.K.ᕣ.C1121;
import ඓ.ῲ.K.ᕣ.ᨨ.AbstractC1027;
import ඓ.ῲ.K.ᕣ.ᨨ.ゎ.AbstractC0967;
import ඓ.ῲ.K.ᕣ.㿎.C1122;

/* renamed from: ඓ.ῲ.K.ᕣ.ᕣ.ʬ.ʬ  reason: contains not printable characters */
/* compiled from: BitmapEncoder */
public class C0854 implements AbstractC1120<Bitmap> {

    /* renamed from: ʬ  reason: contains not printable characters */
    public static final C0850<Bitmap.CompressFormat> f4083 = new C0850<>("com.bumptech.glide.load.resource.bitmap.BitmapEncoder.CompressionFormat", null, C0850.m2468());

    /* renamed from: ῲ  reason: contains not printable characters */
    public static final C0850<Integer> f4084 = C0850.m2469("com.bumptech.glide.load.resource.bitmap.BitmapEncoder.CompressionQuality", 90);

    /* renamed from: K  reason: contains not printable characters */
    public final AbstractC0967 f4085;

    public C0854(AbstractC0967 r1) {
        this.f4085 = r1;
    }

    /* JADX WARNING: Code restructure failed: missing block: B:30:0x0070, code lost:
        if (r6 == null) goto L_0x0075;
     */
    /* JADX WARNING: Removed duplicated region for block: B:29:0x006b A[Catch:{ all -> 0x0060 }] */
    /* JADX WARNING: Removed duplicated region for block: B:39:0x00c5 A[SYNTHETIC, Splitter:B:39:0x00c5] */
    @Override // ඓ.ῲ.K.ᕣ.AbstractC1031
    /* renamed from: K  reason: contains not printable characters */
    public boolean m2475(Object obj, File file, C1121 r11) {
        Throwable th;
        IOException e;
        Bitmap bitmap = (Bitmap) ((AbstractC1027) obj).get();
        Bitmap.CompressFormat compressFormat = (Bitmap.CompressFormat) r11.m3002(f4083);
        if (compressFormat == null) {
            if (bitmap.hasAlpha()) {
                compressFormat = Bitmap.CompressFormat.PNG;
            } else {
                compressFormat = Bitmap.CompressFormat.JPEG;
            }
        }
        Integer.valueOf(bitmap.getWidth());
        Integer.valueOf(bitmap.getHeight());
        long r2 = C0847.m2463();
        int intValue = ((Integer) r11.m3002(f4084)).intValue();
        boolean z = false;
        C1122 r6 = null;
        try {
            OutputStream outputStream = new FileOutputStream(file);
            try {
                r6 = this.f4085 != null ? new C1122(outputStream, this.f4085) : outputStream;
                bitmap.compress(compressFormat, intValue, r6);
                r6.close();
                z = true;
            } catch (IOException e2) {
                e = e2;
                r6 = outputStream;
                try {
                    if (Log.isLoggable("BitmapEncoder", 3)) {
                    }
                } catch (Throwable th2) {
                    th = th2;
                    outputStream = r6;
                    if (outputStream != null) {
                        try {
                            outputStream.close();
                        } catch (IOException unused) {
                        }
                    }
                    throw th;
                }
            } catch (Throwable th3) {
                th = th3;
                if (outputStream != null) {
                }
                throw th;
            }
        } catch (IOException e3) {
            e = e3;
            if (Log.isLoggable("BitmapEncoder", 3)) {
                Log.d("BitmapEncoder", "Failed to encode Bitmap", e);
            }
        }
        try {
            r6.close();
        } catch (IOException unused2) {
        }
        if (Log.isLoggable("BitmapEncoder", 2)) {
            Log.v("BitmapEncoder", "Compressed with type: " + compressFormat + " of size " + C0845.m2454(bitmap) + " in " + C0847.m2462(r2) + ", options format: " + r11.m3002(f4083) + ", hasAlpha: " + bitmap.hasAlpha());
        }
        return z;
    }

    @Override // ඓ.ῲ.K.ᕣ.AbstractC1120
    /* renamed from: K  reason: contains not printable characters */
    public EncodeStrategy m2474(C1121 r1) {
        return EncodeStrategy.TRANSFORMED;
    }
}
