package K.K.K.ʬ;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.graphics.Rect;
import android.graphics.YuvImage;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.lang.ref.SoftReference;

/* renamed from: K.K.K.ʬ.K  reason: contains not printable characters */
public class C2370 {

    /* renamed from: K  reason: contains not printable characters */
    public static Bitmap.Config f8199 = Bitmap.Config.RGB_565;

    /* renamed from: K  reason: contains not printable characters */
    public static Bitmap m6356(Bitmap bitmap, float f) {
        if (f == 0.0f) {
            return bitmap;
        }
        if (bitmap == null) {
            return null;
        }
        int width = bitmap.getWidth();
        int height = bitmap.getHeight();
        Matrix matrix = new Matrix();
        matrix.setRotate(f);
        Bitmap createBitmap = Bitmap.createBitmap(bitmap, 0, 0, width, height, matrix, false);
        bitmap.recycle();
        return createBitmap;
    }

    /* JADX WARNING: Failed to process nested try/catch */
    /* JADX WARNING: Missing exception handler attribute for start block: B:3:0x001c */
    /* renamed from: K  reason: contains not printable characters */
    public static Bitmap m6357(ByteArrayOutputStream byteArrayOutputStream, BitmapFactory.Options options) {
        ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
        Bitmap bitmap = (Bitmap) new SoftReference(BitmapFactory.decodeStream(byteArrayInputStream, null, options)).get();
        byteArrayInputStream.close();
        try {
            byteArrayOutputStream.close();
        } catch (IOException unused) {
        }
        return bitmap;
    }

    /* renamed from: K  reason: contains not printable characters */
    public static Bitmap m6358(byte[] bArr, int i, int i2, int i3, boolean z, boolean z2) {
        YuvImage yuvImage = new YuvImage(bArr, 17, i, i2, null);
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        yuvImage.compressToJpeg(new Rect(0, 0, i, i2), 80, byteArrayOutputStream);
        BitmapFactory.Options options = new BitmapFactory.Options();
        options.inPreferredConfig = f8199;
        Bitmap r7 = m6357(byteArrayOutputStream, options);
        if (z) {
            i3 -= z2 ? 180 : 360;
        }
        return m6356(r7, (float) i3);
    }
}
