a.smali

.class public Lkm/a;
.super Ljava/lang/Object;
.source "BitmapUtils.java"


# direct methods
.method static constructor <clinit>()V
    .registers 1

    return-void
.end method

.method public static a(IIII)I
    .registers 6

    const/4 v0, 0x1

    if-gt p1, p3, :cond_5

    if-le p0, p2, :cond_14

    :cond_5
    div-int/lit8 p1, p1, 0x2

    div-int/lit8 p0, p0, 0x2

    :goto_9
    div-int v1, p1, v0

    if-lt v1, p3, :cond_14

    div-int v1, p0, v0

    if-lt v1, p2, :cond_14

    mul-int/lit8 v0, v0, 0x2

    goto :goto_9

    :cond_14
    return v0
.end method

.method public static a(Landroid/graphics/Bitmap;II)Landroid/graphics/Bitmap;
    .registers 6

    invoke-virtual {p0}, Landroid/graphics/Bitmap;->getWidth()I

    move-result v0

    invoke-virtual {p0}, Landroid/graphics/Bitmap;->getHeight()I

    move-result v1

    invoke-static {p1, p2}, Ljava/lang/Math;->max(II)I

    move-result p1

    int-to-float p2, v0

    int-to-float v0, v1

    div-float/2addr p2, v0

    const/high16 v0, 0x3f800000    # 1.0f

    cmpl-float v0, p2, v0

    if-lez v0, :cond_19

    int-to-float v0, p1

    div-float/2addr v0, p2

    float-to-int p2, v0

    goto :goto_20

    :cond_19
    int-to-float v0, p1

    mul-float v0, v0, p2

    float-to-int p2, v0

    move v2, p2

    move p2, p1

    move p1, v2

    :goto_20
    const/4 v0, 0x1

    invoke-static {p0, p1, p2, v0}, Landroid/graphics/Bitmap;->createScaledBitmap(Landroid/graphics/Bitmap;IIZ)Landroid/graphics/Bitmap;

    move-result-object p0

    return-object p0
.end method

.method public static a([BIILandroid/graphics/BitmapFactory$Options;I)Landroid/graphics/Bitmap;
    .registers 15
    .param p0    # [B
        .annotation build Landroidx/annotation/NonNull;
        .end annotation
    .end param
    .param p1    # I
        .annotation build Landroidx/annotation/NonNull;
        .end annotation
    .end param
    .annotation build Landroidx/annotation/Nullable;
    .end annotation

    .annotation build Landroidx/annotation/WorkerThread;
    .end annotation

    const v0, 0x7fffffff

    if-gtz p1, :cond_8

    const p1, 0x7fffffff

    :cond_8
    if-gtz p2, :cond_d

    const p2, 0x7fffffff

    :cond_d
    const/4 v1, -0x1

    const/4 v2, 0x0

    const/4 v3, 0x1

    const/4 v4, 0x0

    if-ne p4, v1, :cond_54

    :try_start_13
    new-instance p4, Ljava/io/ByteArrayInputStream;

    invoke-direct {p4, p0}, Ljava/io/ByteArrayInputStream;-><init>([B)V
    :try_end_18
    .catch Ljava/io/IOException; {:try_start_13 .. :try_end_18} :catch_40
    .catchall {:try_start_13 .. :try_end_18} :catchall_3e

    :try_start_18
    new-instance v1, Landroidx/exifinterface/media/ExifInterface;

    invoke-direct {v1, p4}, Landroidx/exifinterface/media/ExifInterface;-><init>(Ljava/io/InputStream;)V

    const-string v5, "Orientation"

    invoke-virtual {v1, v5, v3}, Landroidx/exifinterface/media/ExifInterface;->getAttributeInt(Ljava/lang/String;I)I

    move-result v1

    invoke-static {v1}, Lkm/b;->a(I)I

    move-result v5
    :try_end_27
    .catch Ljava/io/IOException; {:try_start_18 .. :try_end_27} :catch_3c
    .catchall {:try_start_18 .. :try_end_27} :catchall_4c

    const/4 v6, 0x2

    if-eq v1, v6, :cond_36

    const/4 v6, 0x4

    if-eq v1, v6, :cond_36

    const/4 v6, 0x5

    if-eq v1, v6, :cond_36

    const/4 v6, 0x7

    if-ne v1, v6, :cond_34

    goto :goto_36

    :cond_34
    const/4 v1, 0x0

    goto :goto_37

    :cond_36
    :goto_36
    const/4 v1, 0x1

    :goto_37
    :try_start_37
    invoke-virtual {p4}, Ljava/io/InputStream;->close()V
    :try_end_3a
    .catch Ljava/lang/Exception; {:try_start_37 .. :try_end_3a} :catch_3a

    :catch_3a
    move p4, v5

    goto :goto_55

    :catch_3c
    move-exception v1

    goto :goto_42

    :catchall_3e
    move-exception p0

    goto :goto_4e

    :catch_40
    move-exception v1

    move-object p4, v2

    :goto_42
    :try_start_42
    invoke-virtual {v1}, Ljava/io/IOException;->printStackTrace()V
    :try_end_45
    .catchall {:try_start_42 .. :try_end_45} :catchall_4c

    if-eqz p4, :cond_4a

    :try_start_47
    invoke-virtual {p4}, Ljava/io/InputStream;->close()V
    :try_end_4a
    .catch Ljava/lang/Exception; {:try_start_47 .. :try_end_4a} :catch_4a

    :catch_4a
    :cond_4a
    const/4 p4, 0x0

    goto :goto_54

    :catchall_4c
    move-exception p0

    move-object v2, p4

    :goto_4e
    if-eqz v2, :cond_53

    :try_start_50
    invoke-virtual {v2}, Ljava/io/InputStream;->close()V
    :try_end_53
    .catch Ljava/lang/Exception; {:try_start_50 .. :try_end_53} :catch_53

    :catch_53
    :cond_53
    throw p0

    :cond_54
    :goto_54
    const/4 v1, 0x0

    :goto_55
    if-lt p1, v0, :cond_60

    if-ge p2, v0, :cond_5a

    goto :goto_60

    :cond_5a
    :try_start_5a
    array-length p1, p0

    invoke-static {p0, v4, p1}, Landroid/graphics/BitmapFactory;->decodeByteArray([BII)Landroid/graphics/Bitmap;

    move-result-object p0

    goto :goto_7f

    :cond_60
    :goto_60
    iput-boolean v3, p3, Landroid/graphics/BitmapFactory$Options;->inJustDecodeBounds:Z

    array-length v0, p0

    invoke-static {p0, v4, v0, p3}, Landroid/graphics/BitmapFactory;->decodeByteArray([BIILandroid/graphics/BitmapFactory$Options;)Landroid/graphics/Bitmap;

    iget v0, p3, Landroid/graphics/BitmapFactory$Options;->outHeight:I

    iget v3, p3, Landroid/graphics/BitmapFactory$Options;->outWidth:I

    rem-int/lit16 v5, p4, 0xb4

    if-eqz v5, :cond_72

    iget v0, p3, Landroid/graphics/BitmapFactory$Options;->outWidth:I

    iget v3, p3, Landroid/graphics/BitmapFactory$Options;->outHeight:I

    :cond_72
    invoke-static {v3, v0, p1, p2}, Lkm/a;->a(IIII)I

    move-result p1

    iput p1, p3, Landroid/graphics/BitmapFactory$Options;->inSampleSize:I

    iput-boolean v4, p3, Landroid/graphics/BitmapFactory$Options;->inJustDecodeBounds:Z

    array-length p1, p0

    invoke-static {p0, v4, p1, p3}, Landroid/graphics/BitmapFactory;->decodeByteArray([BIILandroid/graphics/BitmapFactory$Options;)Landroid/graphics/Bitmap;

    move-result-object p0

    :goto_7f
    if-nez p4, :cond_86

    if-eqz v1, :cond_84

    goto :goto_86

    :cond_84
    move-object v2, p0

    goto :goto_a3

    :cond_86
    :goto_86
    new-instance v8, Landroid/graphics/Matrix;

    invoke-direct {v8}, Landroid/graphics/Matrix;-><init>()V

    int-to-float p1, p4

    invoke-virtual {v8, p1}, Landroid/graphics/Matrix;->setRotate(F)V

    const/4 v4, 0x0

    const/4 v5, 0x0

    invoke-virtual {p0}, Landroid/graphics/Bitmap;->getWidth()I

    move-result v6

    invoke-virtual {p0}, Landroid/graphics/Bitmap;->getHeight()I

    move-result v7

    const/4 v9, 0x1

    move-object v3, p0

    invoke-static/range {v3 .. v9}, Landroid/graphics/Bitmap;->createBitmap(Landroid/graphics/Bitmap;IIIILandroid/graphics/Matrix;Z)Landroid/graphics/Bitmap;

    move-result-object p1

    invoke-virtual {p0}, Landroid/graphics/Bitmap;->recycle()V
    :try_end_a2
    .catch Ljava/lang/OutOfMemoryError; {:try_start_5a .. :try_end_a2} :catch_a3

    move-object v2, p1

    :catch_a3
    :goto_a3
    return-object v2
.end method