174 lines
4.4 KiB
Smali
174 lines
4.4 KiB
Smali
.class public final Lcom/discord/utilities/images/ImageEncoder;
|
|
.super Ljava/lang/Object;
|
|
.source "ImageEncoder.kt"
|
|
|
|
|
|
# direct methods
|
|
.method public constructor <init>()V
|
|
.locals 0
|
|
|
|
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
|
|
|
|
return-void
|
|
.end method
|
|
|
|
.method public static synthetic encodeBitmapAsJpegDataUrl$default(Lcom/discord/utilities/images/ImageEncoder;Landroid/graphics/Bitmap;IILjava/lang/Object;)Ljava/lang/String;
|
|
.locals 0
|
|
|
|
and-int/lit8 p3, p3, 0x2
|
|
|
|
if-eqz p3, :cond_0
|
|
|
|
const/16 p2, 0x64
|
|
|
|
:cond_0
|
|
invoke-virtual {p0, p1, p2}, Lcom/discord/utilities/images/ImageEncoder;->encodeBitmapAsJpegDataUrl(Landroid/graphics/Bitmap;I)Ljava/lang/String;
|
|
|
|
move-result-object p0
|
|
|
|
return-object p0
|
|
.end method
|
|
|
|
|
|
# virtual methods
|
|
.method public final encodeBitmapAsJpegDataUrl(Landroid/graphics/Bitmap;I)Ljava/lang/String;
|
|
.locals 3
|
|
|
|
const-string v0, "bitmap"
|
|
|
|
invoke-static {p1, v0}, Lz/n/c/j;->checkNotNullParameter(Ljava/lang/Object;Ljava/lang/String;)V
|
|
|
|
new-instance v0, Ljava/io/ByteArrayOutputStream;
|
|
|
|
invoke-direct {v0}, Ljava/io/ByteArrayOutputStream;-><init>()V
|
|
|
|
sget-object v1, Landroid/graphics/Bitmap$CompressFormat;->JPEG:Landroid/graphics/Bitmap$CompressFormat;
|
|
|
|
invoke-virtual {p1, v1, p2, v0}, Landroid/graphics/Bitmap;->compress(Landroid/graphics/Bitmap$CompressFormat;ILjava/io/OutputStream;)Z
|
|
|
|
invoke-virtual {v0}, Ljava/io/ByteArrayOutputStream;->toByteArray()[B
|
|
|
|
move-result-object p1
|
|
|
|
const/4 p2, 0x2
|
|
|
|
invoke-static {p1, p2}, Landroid/util/Base64;->encodeToString([BI)Ljava/lang/String;
|
|
|
|
move-result-object p1
|
|
|
|
const-string v0, "Base64.encodeToString(jp\u2026eArray(), Base64.NO_WRAP)"
|
|
|
|
invoke-static {p1, v0}, Lz/n/c/j;->checkNotNullExpressionValue(Ljava/lang/Object;Ljava/lang/String;)V
|
|
|
|
new-array v0, p2, [Ljava/lang/Object;
|
|
|
|
const/4 v1, 0x0
|
|
|
|
const-string v2, "image/jpeg"
|
|
|
|
aput-object v2, v0, v1
|
|
|
|
const/4 v1, 0x1
|
|
|
|
aput-object p1, v0, v1
|
|
|
|
const-string p1, "data:%s;base64,%s"
|
|
|
|
const-string v1, "java.lang.String.format(format, *args)"
|
|
|
|
invoke-static {v0, p2, p1, v1}, Lf/e/c/a/a;->B([Ljava/lang/Object;ILjava/lang/String;Ljava/lang/String;)Ljava/lang/String;
|
|
|
|
move-result-object p1
|
|
|
|
return-object p1
|
|
.end method
|
|
|
|
.method public final getBase64EncodedString(Ljava/io/InputStream;I)Ljava/lang/String;
|
|
.locals 4
|
|
.annotation system Ldalvik/annotation/Throws;
|
|
value = {
|
|
Ljava/io/IOException;
|
|
}
|
|
.end annotation
|
|
|
|
const-string v0, "inputStream"
|
|
|
|
invoke-static {p1, v0}, Lz/n/c/j;->checkNotNullParameter(Ljava/lang/Object;Ljava/lang/String;)V
|
|
|
|
const/16 v0, 0x2000
|
|
|
|
new-array v0, v0, [B
|
|
|
|
new-instance v1, Ljava/io/ByteArrayOutputStream;
|
|
|
|
invoke-direct {v1}, Ljava/io/ByteArrayOutputStream;-><init>()V
|
|
|
|
:goto_0
|
|
invoke-virtual {p1, v0}, Ljava/io/InputStream;->read([B)I
|
|
|
|
move-result v2
|
|
|
|
const/4 v3, -0x1
|
|
|
|
if-eq v2, v3, :cond_0
|
|
|
|
const/4 v3, 0x0
|
|
|
|
invoke-virtual {v1, v0, v3, v2}, Ljava/io/ByteArrayOutputStream;->write([BII)V
|
|
|
|
goto :goto_0
|
|
|
|
:cond_0
|
|
invoke-virtual {v1}, Ljava/io/ByteArrayOutputStream;->toByteArray()[B
|
|
|
|
move-result-object p1
|
|
|
|
invoke-static {p1, p2}, Landroid/util/Base64;->encodeToString([BI)Ljava/lang/String;
|
|
|
|
move-result-object p1
|
|
|
|
return-object p1
|
|
.end method
|
|
|
|
.method public final getDataUrl(Ljava/lang/String;Ljava/io/InputStream;)Ljava/lang/String;
|
|
.locals 3
|
|
.annotation system Ldalvik/annotation/Throws;
|
|
value = {
|
|
Ljava/io/IOException;
|
|
}
|
|
.end annotation
|
|
|
|
const-string v0, "mimeType"
|
|
|
|
invoke-static {p1, v0}, Lz/n/c/j;->checkNotNullParameter(Ljava/lang/Object;Ljava/lang/String;)V
|
|
|
|
const-string v0, "inputStream"
|
|
|
|
invoke-static {p2, v0}, Lz/n/c/j;->checkNotNullParameter(Ljava/lang/Object;Ljava/lang/String;)V
|
|
|
|
const/4 v0, 0x2
|
|
|
|
new-array v1, v0, [Ljava/lang/Object;
|
|
|
|
const/4 v2, 0x0
|
|
|
|
aput-object p1, v1, v2
|
|
|
|
invoke-virtual {p0, p2, v0}, Lcom/discord/utilities/images/ImageEncoder;->getBase64EncodedString(Ljava/io/InputStream;I)Ljava/lang/String;
|
|
|
|
move-result-object p1
|
|
|
|
const/4 p2, 0x1
|
|
|
|
aput-object p1, v1, p2
|
|
|
|
const-string p1, "data:%s;base64,%s"
|
|
|
|
const-string p2, "java.lang.String.format(format, *args)"
|
|
|
|
invoke-static {v1, v0, p1, p2}, Lf/e/c/a/a;->B([Ljava/lang/Object;ILjava/lang/String;Ljava/lang/String;)Ljava/lang/String;
|
|
|
|
move-result-object p1
|
|
|
|
return-object p1
|
|
.end method
|