BitmapEncoder.smali
.class public Lcom/bumptech/glide/load/resource/bitmap/BitmapEncoder;
.super Ljava/lang/Object;
.source "BitmapEncoder.java"
# interfaces
.implements Lcom/bumptech/glide/load/ResourceEncoder;
# annotations
.annotation system Ldalvik/annotation/Signature;
value = {
"Ljava/lang/Object;",
"Lcom/bumptech/glide/load/ResourceEncoder<",
"Landroid/graphics/Bitmap;",
">;"
}
.end annotation
# static fields
.field public static final COMPRESSION_FORMAT:Lcom/bumptech/glide/load/Option;
.annotation system Ldalvik/annotation/Signature;
value = {
"Lcom/bumptech/glide/load/Option<",
"Landroid/graphics/Bitmap$CompressFormat;",
">;"
}
.end annotation
.end field
.field public static final COMPRESSION_QUALITY:Lcom/bumptech/glide/load/Option;
.annotation system Ldalvik/annotation/Signature;
value = {
"Lcom/bumptech/glide/load/Option<",
"Ljava/lang/Integer;",
">;"
}
.end annotation
.end field
.field private static final TAG:Ljava/lang/String; = "BitmapEncoder"
# instance fields
.field private final arrayPool:Lcom/bumptech/glide/load/engine/bitmap_recycle/ArrayPool;
# direct methods
.method static constructor <clinit>()V
.registers 2
const/16 v0, 0x5a
.line 42
invoke-static {v0}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
move-result-object v0
const-string v1, "com.bumptech.glide.load.resource.bitmap.BitmapEncoder.CompressionQuality"
.line 41
invoke-static {v1, v0}, Lcom/bumptech/glide/load/Option;->memory(Ljava/lang/String;Ljava/lang/Object;)Lcom/bumptech/glide/load/Option;
move-result-object v0
sput-object v0, Lcom/bumptech/glide/load/resource/bitmap/BitmapEncoder;->COMPRESSION_QUALITY:Lcom/bumptech/glide/load/Option;
const-string v0, "com.bumptech.glide.load.resource.bitmap.BitmapEncoder.CompressionFormat"
.line 51
invoke-static {v0}, Lcom/bumptech/glide/load/Option;->memory(Ljava/lang/String;)Lcom/bumptech/glide/load/Option;
move-result-object v0
sput-object v0, Lcom/bumptech/glide/load/resource/bitmap/BitmapEncoder;->COMPRESSION_FORMAT:Lcom/bumptech/glide/load/Option;
return-void
.end method
.method public constructor <init>()V
.registers 2
.annotation runtime Ljava/lang/Deprecated;
.end annotation
.line 66
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
const/4 v0, 0x0
.line 67
iput-object v0, p0, Lcom/bumptech/glide/load/resource/bitmap/BitmapEncoder;->arrayPool:Lcom/bumptech/glide/load/engine/bitmap_recycle/ArrayPool;
return-void
.end method
.method public constructor <init>(Lcom/bumptech/glide/load/engine/bitmap_recycle/ArrayPool;)V
.registers 2
.line 58
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
.line 59
iput-object p1, p0, Lcom/bumptech/glide/load/resource/bitmap/BitmapEncoder;->arrayPool:Lcom/bumptech/glide/load/engine/bitmap_recycle/ArrayPool;
return-void
.end method
.method private getFormat(Landroid/graphics/Bitmap;Lcom/bumptech/glide/load/Options;)Landroid/graphics/Bitmap$CompressFormat;
.registers 4
.line 118
sget-object v0, Lcom/bumptech/glide/load/resource/bitmap/BitmapEncoder;->COMPRESSION_FORMAT:Lcom/bumptech/glide/load/Option;
invoke-virtual {p2, v0}, Lcom/bumptech/glide/load/Options;->get(Lcom/bumptech/glide/load/Option;)Ljava/lang/Object;
move-result-object p2
check-cast p2, Landroid/graphics/Bitmap$CompressFormat;
if-eqz p2, :cond_b
return-object p2
.line 121
:cond_b
invoke-virtual {p1}, Landroid/graphics/Bitmap;->hasAlpha()Z
move-result p1
if-eqz p1, :cond_14
.line 122
sget-object p1, Landroid/graphics/Bitmap$CompressFormat;->PNG:Landroid/graphics/Bitmap$CompressFormat;
return-object p1
.line 124
:cond_14
sget-object p1, Landroid/graphics/Bitmap$CompressFormat;->JPEG:Landroid/graphics/Bitmap$CompressFormat;
return-object p1
.end method
# virtual methods
.method public encode(Lcom/bumptech/glide/load/engine/Resource;Ljava/io/File;Lcom/bumptech/glide/load/Options;)Z
.registers 12
.annotation system Ldalvik/annotation/Signature;
value = {
"(",
"Lcom/bumptech/glide/load/engine/Resource<",
"Landroid/graphics/Bitmap;",
">;",
"Ljava/io/File;",
"Lcom/bumptech/glide/load/Options;",
")Z"
}
.end annotation
const-string v0, "BitmapEncoder"
.line 73
invoke-interface {p1}, Lcom/bumptech/glide/load/engine/Resource;->get()Ljava/lang/Object;
move-result-object p1
check-cast p1, Landroid/graphics/Bitmap;
.line 74
invoke-direct {p0, p1, p3}, Lcom/bumptech/glide/load/resource/bitmap/BitmapEncoder;->getFormat(Landroid/graphics/Bitmap;Lcom/bumptech/glide/load/Options;)Landroid/graphics/Bitmap$CompressFormat;
move-result-object v1
.line 76
invoke-virtual {p1}, Landroid/graphics/Bitmap;->getWidth()I
move-result v2
invoke-static {v2}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
move-result-object v2
invoke-virtual {p1}, Landroid/graphics/Bitmap;->getHeight()I
move-result v3
invoke-static {v3}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
move-result-object v3
const-string v4, "encode: [%dx%d] %s"
invoke-static {v4, v2, v3, v1}, Lcom/bumptech/glide/util/pool/GlideTrace;->beginSectionFormat(Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V
.line 78
:try_start_21
invoke-static {}, Lcom/bumptech/glide/util/LogTime;->getLogTime()J
move-result-wide v2
.line 79
sget-object v4, Lcom/bumptech/glide/load/resource/bitmap/BitmapEncoder;->COMPRESSION_QUALITY:Lcom/bumptech/glide/load/Option;
invoke-virtual {p3, v4}, Lcom/bumptech/glide/load/Options;->get(Lcom/bumptech/glide/load/Option;)Ljava/lang/Object;
move-result-object v4
check-cast v4, Ljava/lang/Integer;
invoke-virtual {v4}, Ljava/lang/Integer;->intValue()I
move-result v4
:try_end_31
.catchall {:try_start_21 .. :try_end_31} :catchall_c2
const/4 v5, 0x0
const/4 v6, 0x0
.line 84
:try_start_33
new-instance v7, Ljava/io/FileOutputStream;
invoke-direct {v7, p2}, Ljava/io/FileOutputStream;-><init>(Ljava/io/File;)V
:try_end_38
.catch Ljava/io/IOException; {:try_start_33 .. :try_end_38} :catch_5b
.catchall {:try_start_33 .. :try_end_38} :catchall_59
.line 85
:try_start_38
iget-object p2, p0, Lcom/bumptech/glide/load/resource/bitmap/BitmapEncoder;->arrayPool:Lcom/bumptech/glide/load/engine/bitmap_recycle/ArrayPool;
if-eqz p2, :cond_45
.line 86
new-instance p2, Lcom/bumptech/glide/load/data/BufferedOutputStream;
iget-object v6, p0, Lcom/bumptech/glide/load/resource/bitmap/BitmapEncoder;->arrayPool:Lcom/bumptech/glide/load/engine/bitmap_recycle/ArrayPool;
invoke-direct {p2, v7, v6}, Lcom/bumptech/glide/load/data/BufferedOutputStream;-><init>(Ljava/io/OutputStream;Lcom/bumptech/glide/load/engine/bitmap_recycle/ArrayPool;)V
:try_end_43
.catch Ljava/io/IOException; {:try_start_38 .. :try_end_43} :catch_56
.catchall {:try_start_38 .. :try_end_43} :catchall_53
move-object v6, p2
goto :goto_46
:cond_45
move-object v6, v7
.line 88
:goto_46
:try_start_46
invoke-virtual {p1, v1, v4, v6}, Landroid/graphics/Bitmap;->compress(Landroid/graphics/Bitmap$CompressFormat;ILjava/io/OutputStream;)Z
.line 89
invoke-virtual {v6}, Ljava/io/OutputStream;->close()V
:try_end_4c
.catch Ljava/io/IOException; {:try_start_46 .. :try_end_4c} :catch_5b
.catchall {:try_start_46 .. :try_end_4c} :catchall_59
const/4 v5, 0x1
if-eqz v6, :cond_6b
.line 98
:goto_4f
:try_start_4f
invoke-virtual {v6}, Ljava/io/OutputStream;->close()V
:try_end_52
.catch Ljava/io/IOException; {:try_start_4f .. :try_end_52} :catch_6b
.catchall {:try_start_4f .. :try_end_52} :catchall_c2
goto :goto_6b
:catchall_53
move-exception p1
move-object v6, v7
goto :goto_bc
:catch_56
move-exception p2
move-object v6, v7
goto :goto_5c
:catchall_59
move-exception p1
goto :goto_bc
:catch_5b
move-exception p2
:goto_5c
const/4 v4, 0x3
.line 92
:try_start_5d
invoke-static {v0, v4}, Landroid/util/Log;->isLoggable(Ljava/lang/String;I)Z
move-result v4
if-eqz v4, :cond_68
const-string v4, "Failed to encode Bitmap"
.line 93
invoke-static {v0, v4, p2}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)I
:try_end_68
.catchall {:try_start_5d .. :try_end_68} :catchall_59
:cond_68
if-eqz v6, :cond_6b
goto :goto_4f
:catch_6b
:cond_6b
:goto_6b
const/4 p2, 0x2
.line 105
:try_start_6c
invoke-static {v0, p2}, Landroid/util/Log;->isLoggable(Ljava/lang/String;I)Z
move-result p2
if-eqz p2, :cond_b8
.line 106
new-instance p2, Ljava/lang/StringBuilder;
invoke-direct {p2}, Ljava/lang/StringBuilder;-><init>()V
const-string v4, "Compressed with type: "
invoke-virtual {p2, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
invoke-virtual {p2, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;
const-string v1, " of size "
invoke-virtual {p2, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
invoke-static {p1}, Lcom/bumptech/glide/util/Util;->getBitmapByteSize(Landroid/graphics/Bitmap;)I
move-result v1
invoke-virtual {p2, v1}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;
const-string v1, " in "
invoke-virtual {p2, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
.line 107
invoke-static {v2, v3}, Lcom/bumptech/glide/util/LogTime;->getElapsedMillis(J)D
move-result-wide v1
invoke-virtual {p2, v1, v2}, Ljava/lang/StringBuilder;->append(D)Ljava/lang/StringBuilder;
const-string v1, ", options format: "
invoke-virtual {p2, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
sget-object v1, Lcom/bumptech/glide/load/resource/bitmap/BitmapEncoder;->COMPRESSION_FORMAT:Lcom/bumptech/glide/load/Option;
.line 108
invoke-virtual {p3, v1}, Lcom/bumptech/glide/load/Options;->get(Lcom/bumptech/glide/load/Option;)Ljava/lang/Object;
move-result-object p3
invoke-virtual {p2, p3}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;
const-string p3, ", hasAlpha: "
invoke-virtual {p2, p3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
.line 109
invoke-virtual {p1}, Landroid/graphics/Bitmap;->hasAlpha()Z
move-result p1
invoke-virtual {p2, p1}, Ljava/lang/StringBuilder;->append(Z)Ljava/lang/StringBuilder;
invoke-virtual {p2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object p1
.line 106
invoke-static {v0, p1}, Landroid/util/Log;->v(Ljava/lang/String;Ljava/lang/String;)I
:try_end_b8
.catchall {:try_start_6c .. :try_end_b8} :catchall_c2
.line 113
:cond_b8
invoke-static {}, Lcom/bumptech/glide/util/pool/GlideTrace;->endSection()V
return v5
:goto_bc
if-eqz v6, :cond_c1
.line 98
:try_start_be
invoke-virtual {v6}, Ljava/io/OutputStream;->close()V
:try_end_c1
.catch Ljava/io/IOException; {:try_start_be .. :try_end_c1} :catch_c1
.catchall {:try_start_be .. :try_end_c1} :catchall_c2
.line 101
:catch_c1
:cond_c1
:try_start_c1
throw p1
:try_end_c2
.catchall {:try_start_c1 .. :try_end_c2} :catchall_c2
:catchall_c2
move-exception p1
.line 113
invoke-static {}, Lcom/bumptech/glide/util/pool/GlideTrace;->endSection()V
throw p1
.end method
.method public bridge synthetic encode(Ljava/lang/Object;Ljava/io/File;Lcom/bumptech/glide/load/Options;)Z
.registers 4
.line 35
check-cast p1, Lcom/bumptech/glide/load/engine/Resource;
invoke-virtual {p0, p1, p2, p3}, Lcom/bumptech/glide/load/resource/bitmap/BitmapEncoder;->encode(Lcom/bumptech/glide/load/engine/Resource;Ljava/io/File;Lcom/bumptech/glide/load/Options;)Z
move-result p1
return p1
.end method
.method public getEncodeStrategy(Lcom/bumptech/glide/load/Options;)Lcom/bumptech/glide/load/EncodeStrategy;
.registers 2
.line 131
sget-object p1, Lcom/bumptech/glide/load/EncodeStrategy;->TRANSFORMED:Lcom/bumptech/glide/load/EncodeStrategy;
return-object p1
.end method