package K.K.㸾.K;

import ai.advance.liveness.lib.Detector;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.graphics.Rect;
import android.graphics.YuvImage;
import android.util.Base64;
import com.facebook.internal.AnalyticsEvents;
import java.io.ByteArrayOutputStream;
import org.json.JSONException;
import org.json.JSONObject;
import K.K.K.ʬ.C2369;
import K.K.K.ʬ.C2370;

/* renamed from: K.K.㸾.K.ඓ  reason: contains not printable characters */
public class C2385 {

    /* renamed from: ʬ  reason: contains not printable characters */
    public int f8249;

    /* renamed from: ඓ  reason: contains not printable characters */
    public int f8250;

    /* renamed from: ᨨ  reason: contains not printable characters */
    public Detector.ActionStatus f8251;

    /* renamed from: ῲ  reason: contains not printable characters */
    public int f8252;

    /* renamed from: ⁱ  reason: contains not printable characters */
    public Detector.DetectionType f8253;

    /* renamed from: K  reason: contains not printable characters */
    public byte[] f8254;

    /* renamed from: 㳳  reason: contains not printable characters */
    public int f8255;

    /* renamed from: 㴹  reason: contains not printable characters */
    public C2389 f8256;

    /* renamed from: 㸾  reason: contains not printable characters */
    public int f8257;

    /* renamed from: 㿎  reason: contains not printable characters */
    public Detector.WarnCode f8258;

    public C2385() {
    }

    public C2385(byte[] bArr, int i, int i2, int i3, Detector.DetectionType detectionType) {
        this.f8253 = detectionType;
        this.f8255 = i;
        this.f8254 = bArr;
        this.f8252 = i2;
        this.f8249 = i3;
        this.f8256 = null;
    }

    /* renamed from: ῲ  reason: contains not printable characters */
    public String m6385() {
        Bitmap r0 = C2370.m6358(this.f8254, this.f8252, this.f8249, this.f8255, true, C2388.f8274 == C2369.m6275());
        Matrix matrix = new Matrix();
        matrix.postScale(-1.0f, 1.0f);
        Bitmap createBitmap = Bitmap.createBitmap(r0, 0, 0, r0.getWidth(), r0.getHeight(), matrix, true);
        r0.recycle();
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        createBitmap.compress(Bitmap.CompressFormat.JPEG, 100, byteArrayOutputStream);
        byte[] byteArray = byteArrayOutputStream.toByteArray();
        if (!r0.isRecycled()) {
            r0.recycle();
        }
        return Base64.encodeToString(byteArray, 2);
    }

    /* renamed from: K  reason: contains not printable characters */
    public final Bitmap m6386(int i, int i2) {
        Rect rect;
        YuvImage yuvImage = new YuvImage(this.f8254, 17, this.f8252, this.f8249, null);
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        if (C2388.f8274 == C2369.m6291()) {
            int i3 = this.f8249;
            rect = new Rect(0, 0, i3, i3);
        } else {
            int i4 = this.f8252;
            int i5 = this.f8249;
            rect = new Rect(i4 - i5, 0, i4, i5);
        }
        yuvImage.compressToJpeg(rect, i2, byteArrayOutputStream);
        BitmapFactory.Options options = new BitmapFactory.Options();
        options.inSampleSize = this.f8249 / i;
        options.inPreferredConfig = Bitmap.Config.ARGB_8888;
        Bitmap r9 = C2370.m6356(C2370.m6357(byteArrayOutputStream, options), (float) (C2388.f8274 == C2369.m6291() ? this.f8255 : this.f8255 - 180));
        if (r9.getWidth() == i) {
            return r9;
        }
        Matrix matrix = new Matrix();
        float width = ((float) i) / ((float) r9.getWidth());
        matrix.setScale(width, width);
        Bitmap createBitmap = Bitmap.createBitmap(r9, 0, 0, r9.getWidth(), r9.getHeight(), matrix, true);
        r9.recycle();
        return createBitmap;
    }

    /* renamed from: K  reason: contains not printable characters */
    public String m6387() {
        return m6388(300);
    }

    /* renamed from: K  reason: contains not printable characters */
    public void m6389(JSONObject jSONObject) {
        try {
            this.f8258 = Detector.WarnCode.valueOf(jSONObject.getInt("code"));
            this.f8251 = Detector.ActionStatus.valueOf(jSONObject.getInt(AnalyticsEvents.PARAMETER_SHARE_DIALOG_CONTENT_STATUS));
            if (!jSONObject.getString("faceInfo").equals("")) {
                this.f8256 = C2369.m6325(new JSONObject(jSONObject.getString("faceInfo")));
            }
        } catch (JSONException e) {
            e.toString();
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public String m6388(int i) {
        Bitmap r4 = m6386(i, 100);
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        r4.compress(Bitmap.CompressFormat.JPEG, 100, byteArrayOutputStream);
        byte[] byteArray = byteArrayOutputStream.toByteArray();
        if (!r4.isRecycled()) {
            r4.recycle();
        }
        return Base64.encodeToString(byteArray, 2);
    }
}
