398 lines
8.9 KiB
Smali
398 lines
8.9 KiB
Smali
.class public Lcom/moji/tool/BitmapTool;
|
|
.super Ljava/lang/Object;
|
|
.source "BitmapTool.java"
|
|
|
|
|
|
# static fields
|
|
.field private static final a:Ljava/lang/String; = "BitmapTool"
|
|
|
|
.field private static b:Ljava/lang/String; = ""
|
|
|
|
|
|
# direct methods
|
|
.method static constructor <clinit>()V
|
|
.locals 0
|
|
|
|
return-void
|
|
.end method
|
|
|
|
.method public constructor <init>()V
|
|
.locals 0
|
|
|
|
.line 22
|
|
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
|
|
|
|
return-void
|
|
.end method
|
|
|
|
.method public static a(I)Landroid/graphics/Bitmap;
|
|
.locals 5
|
|
|
|
.line 218
|
|
invoke-static {}, Lcom/moji/tool/AppDelegate;->a()Landroid/content/Context;
|
|
|
|
move-result-object v0
|
|
|
|
invoke-virtual {v0}, Landroid/content/Context;->getResources()Landroid/content/res/Resources;
|
|
|
|
move-result-object v0
|
|
|
|
invoke-virtual {v0, p0}, Landroid/content/res/Resources;->getDrawable(I)Landroid/graphics/drawable/Drawable;
|
|
|
|
move-result-object p0
|
|
|
|
.line 219
|
|
new-instance v0, Landroid/graphics/Canvas;
|
|
|
|
invoke-direct {v0}, Landroid/graphics/Canvas;-><init>()V
|
|
|
|
.line 220
|
|
invoke-virtual {p0}, Landroid/graphics/drawable/Drawable;->getIntrinsicWidth()I
|
|
|
|
move-result v1
|
|
|
|
invoke-virtual {p0}, Landroid/graphics/drawable/Drawable;->getIntrinsicHeight()I
|
|
|
|
move-result v2
|
|
|
|
sget-object v3, Landroid/graphics/Bitmap$Config;->ARGB_8888:Landroid/graphics/Bitmap$Config;
|
|
|
|
invoke-static {v1, v2, v3}, Landroid/graphics/Bitmap;->createBitmap(IILandroid/graphics/Bitmap$Config;)Landroid/graphics/Bitmap;
|
|
|
|
move-result-object v1
|
|
|
|
.line 221
|
|
invoke-virtual {v0, v1}, Landroid/graphics/Canvas;->setBitmap(Landroid/graphics/Bitmap;)V
|
|
|
|
.line 222
|
|
invoke-virtual {p0}, Landroid/graphics/drawable/Drawable;->getIntrinsicWidth()I
|
|
|
|
move-result v2
|
|
|
|
invoke-virtual {p0}, Landroid/graphics/drawable/Drawable;->getIntrinsicHeight()I
|
|
|
|
move-result v3
|
|
|
|
const/4 v4, 0x0
|
|
|
|
invoke-virtual {p0, v4, v4, v2, v3}, Landroid/graphics/drawable/Drawable;->setBounds(IIII)V
|
|
|
|
.line 223
|
|
invoke-virtual {p0, v0}, Landroid/graphics/drawable/Drawable;->draw(Landroid/graphics/Canvas;)V
|
|
|
|
return-object v1
|
|
.end method
|
|
|
|
.method public static a(Landroid/view/View;)Landroid/graphics/Bitmap;
|
|
.locals 5
|
|
|
|
const/4 v0, 0x0
|
|
|
|
if-nez p0, :cond_0
|
|
|
|
return-object v0
|
|
|
|
:cond_0
|
|
const/4 v1, 0x0
|
|
|
|
.line 181
|
|
:try_start_0
|
|
invoke-static {v1, v1}, Landroid/view/View$MeasureSpec;->makeMeasureSpec(II)I
|
|
|
|
move-result v2
|
|
|
|
invoke-static {v1, v1}, Landroid/view/View$MeasureSpec;->makeMeasureSpec(II)I
|
|
|
|
move-result v3
|
|
|
|
invoke-virtual {p0, v2, v3}, Landroid/view/View;->measure(II)V
|
|
|
|
const-string v2, "convertViewToBitmap"
|
|
|
|
.line 182
|
|
new-instance v3, Ljava/lang/StringBuilder;
|
|
|
|
invoke-direct {v3}, Ljava/lang/StringBuilder;-><init>()V
|
|
|
|
const-string v4, "view.getMeasuredWidth() "
|
|
|
|
invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
|
|
|
|
invoke-virtual {p0}, Landroid/view/View;->getMeasuredWidth()I
|
|
|
|
move-result v4
|
|
|
|
invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;
|
|
|
|
invoke-virtual {v3}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
|
|
|
|
move-result-object v3
|
|
|
|
invoke-static {v2, v3}, Lcom/moji/tool/log/MJLogger;->b(Ljava/lang/String;Ljava/lang/String;)V
|
|
|
|
.line 183
|
|
invoke-virtual {p0}, Landroid/view/View;->getMeasuredWidth()I
|
|
|
|
move-result v2
|
|
|
|
invoke-virtual {p0}, Landroid/view/View;->getMeasuredHeight()I
|
|
|
|
move-result v3
|
|
|
|
invoke-virtual {p0, v1, v1, v2, v3}, Landroid/view/View;->layout(IIII)V
|
|
|
|
.line 184
|
|
invoke-virtual {p0}, Landroid/view/View;->buildDrawingCache()V
|
|
|
|
.line 185
|
|
invoke-virtual {p0}, Landroid/view/View;->getDrawingCache()Landroid/graphics/Bitmap;
|
|
|
|
move-result-object p0
|
|
:try_end_0
|
|
.catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0
|
|
|
|
return-object p0
|
|
|
|
:catch_0
|
|
move-exception p0
|
|
|
|
const-string v1, "convertViewToBitmap"
|
|
|
|
.line 188
|
|
invoke-static {v1, p0}, Lcom/moji/tool/log/MJLogger;->a(Ljava/lang/String;Ljava/lang/Throwable;)V
|
|
|
|
return-object v0
|
|
.end method
|
|
|
|
.method public static a(Landroid/graphics/Bitmap;Ljava/lang/String;)Ljava/lang/Boolean;
|
|
.locals 4
|
|
|
|
const/4 v0, 0x0
|
|
|
|
if-nez p0, :cond_0
|
|
|
|
.line 283
|
|
invoke-static {v0}, Ljava/lang/Boolean;->valueOf(Z)Ljava/lang/Boolean;
|
|
|
|
move-result-object p0
|
|
|
|
return-object p0
|
|
|
|
:cond_0
|
|
const/4 v1, 0x0
|
|
|
|
.line 286
|
|
:try_start_0
|
|
new-instance v2, Ljava/io/File;
|
|
|
|
invoke-direct {v2, p1}, Ljava/io/File;-><init>(Ljava/lang/String;)V
|
|
|
|
.line 287
|
|
invoke-virtual {v2}, Ljava/io/File;->getParentFile()Ljava/io/File;
|
|
|
|
move-result-object p1
|
|
|
|
.line 288
|
|
invoke-virtual {p1}, Ljava/io/File;->exists()Z
|
|
|
|
move-result v3
|
|
|
|
if-nez v3, :cond_1
|
|
|
|
invoke-virtual {p1}, Ljava/io/File;->mkdirs()Z
|
|
|
|
move-result p1
|
|
|
|
if-nez p1, :cond_1
|
|
|
|
.line 289
|
|
invoke-static {v0}, Ljava/lang/Boolean;->valueOf(Z)Ljava/lang/Boolean;
|
|
|
|
move-result-object p0
|
|
|
|
return-object p0
|
|
|
|
.line 291
|
|
:cond_1
|
|
new-instance p1, Ljava/io/FileOutputStream;
|
|
|
|
invoke-direct {p1, v2}, Ljava/io/FileOutputStream;-><init>(Ljava/io/File;)V
|
|
:try_end_0
|
|
.catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_2
|
|
.catchall {:try_start_0 .. :try_end_0} :catchall_1
|
|
|
|
.line 292
|
|
:try_start_1
|
|
sget-object v1, Landroid/graphics/Bitmap$CompressFormat;->PNG:Landroid/graphics/Bitmap$CompressFormat;
|
|
|
|
const/16 v2, 0x64
|
|
|
|
invoke-virtual {p0, v1, v2, p1}, Landroid/graphics/Bitmap;->compress(Landroid/graphics/Bitmap$CompressFormat;ILjava/io/OutputStream;)Z
|
|
:try_end_1
|
|
.catch Ljava/lang/Exception; {:try_start_1 .. :try_end_1} :catch_1
|
|
.catchall {:try_start_1 .. :try_end_1} :catchall_0
|
|
|
|
.line 299
|
|
:try_start_2
|
|
invoke-virtual {p1}, Ljava/io/FileOutputStream;->close()V
|
|
:try_end_2
|
|
.catch Ljava/io/IOException; {:try_start_2 .. :try_end_2} :catch_0
|
|
|
|
const/4 p0, 0x1
|
|
|
|
.line 306
|
|
invoke-static {p0}, Ljava/lang/Boolean;->valueOf(Z)Ljava/lang/Boolean;
|
|
|
|
move-result-object p0
|
|
|
|
return-object p0
|
|
|
|
:catch_0
|
|
move-exception p0
|
|
|
|
.line 302
|
|
invoke-virtual {p0}, Ljava/io/IOException;->printStackTrace()V
|
|
|
|
.line 303
|
|
invoke-static {v0}, Ljava/lang/Boolean;->valueOf(Z)Ljava/lang/Boolean;
|
|
|
|
move-result-object p0
|
|
|
|
return-object p0
|
|
|
|
:catchall_0
|
|
move-exception p0
|
|
|
|
move-object v1, p1
|
|
|
|
goto :goto_1
|
|
|
|
:catch_1
|
|
move-exception p0
|
|
|
|
move-object v1, p1
|
|
|
|
goto :goto_0
|
|
|
|
:catchall_1
|
|
move-exception p0
|
|
|
|
goto :goto_1
|
|
|
|
:catch_2
|
|
move-exception p0
|
|
|
|
.line 294
|
|
:goto_0
|
|
:try_start_3
|
|
invoke-virtual {p0}, Ljava/lang/Exception;->printStackTrace()V
|
|
|
|
.line 295
|
|
invoke-static {v0}, Ljava/lang/Boolean;->valueOf(Z)Ljava/lang/Boolean;
|
|
|
|
move-result-object p0
|
|
:try_end_3
|
|
.catchall {:try_start_3 .. :try_end_3} :catchall_1
|
|
|
|
if-eqz v1, :cond_2
|
|
|
|
.line 299
|
|
:try_start_4
|
|
invoke-virtual {v1}, Ljava/io/FileOutputStream;->close()V
|
|
|
|
:cond_2
|
|
return-object p0
|
|
|
|
:goto_1
|
|
if-eqz v1, :cond_3
|
|
|
|
invoke-virtual {v1}, Ljava/io/FileOutputStream;->close()V
|
|
:try_end_4
|
|
.catch Ljava/io/IOException; {:try_start_4 .. :try_end_4} :catch_0
|
|
|
|
.line 305
|
|
:cond_3
|
|
throw p0
|
|
.end method
|
|
|
|
.method public static a(Landroid/graphics/Bitmap;)Z
|
|
.locals 1
|
|
|
|
if-eqz p0, :cond_0
|
|
|
|
.line 33
|
|
invoke-virtual {p0}, Landroid/graphics/Bitmap;->isRecycled()Z
|
|
|
|
move-result v0
|
|
|
|
if-nez v0, :cond_0
|
|
|
|
.line 34
|
|
invoke-virtual {p0}, Landroid/graphics/Bitmap;->recycle()V
|
|
|
|
const/4 p0, 0x1
|
|
|
|
return p0
|
|
|
|
:cond_0
|
|
const/4 p0, 0x0
|
|
|
|
return p0
|
|
.end method
|
|
|
|
.method public static a(Landroid/graphics/Bitmap;J)[B
|
|
.locals 4
|
|
|
|
.line 270
|
|
new-instance v0, Ljava/io/ByteArrayOutputStream;
|
|
|
|
invoke-direct {v0}, Ljava/io/ByteArrayOutputStream;-><init>()V
|
|
|
|
.line 272
|
|
sget-object v1, Landroid/graphics/Bitmap$CompressFormat;->JPEG:Landroid/graphics/Bitmap$CompressFormat;
|
|
|
|
const/16 v2, 0x64
|
|
|
|
invoke-virtual {p0, v1, v2, v0}, Landroid/graphics/Bitmap;->compress(Landroid/graphics/Bitmap$CompressFormat;ILjava/io/OutputStream;)Z
|
|
|
|
.line 274
|
|
:goto_0
|
|
invoke-virtual {v0}, Ljava/io/ByteArrayOutputStream;->toByteArray()[B
|
|
|
|
move-result-object v1
|
|
|
|
array-length v1, v1
|
|
|
|
int-to-float v1, v1
|
|
|
|
const/high16 v3, 0x44800000 # 1024.0f
|
|
|
|
div-float/2addr v1, v3
|
|
|
|
long-to-float v3, p1
|
|
|
|
cmpl-float v1, v1, v3
|
|
|
|
if-lez v1, :cond_0
|
|
|
|
.line 275
|
|
invoke-virtual {v0}, Ljava/io/ByteArrayOutputStream;->reset()V
|
|
|
|
.line 276
|
|
sget-object v1, Landroid/graphics/Bitmap$CompressFormat;->JPEG:Landroid/graphics/Bitmap$CompressFormat;
|
|
|
|
invoke-virtual {p0, v1, v2, v0}, Landroid/graphics/Bitmap;->compress(Landroid/graphics/Bitmap$CompressFormat;ILjava/io/OutputStream;)Z
|
|
|
|
add-int/lit8 v2, v2, -0xa
|
|
|
|
goto :goto_0
|
|
|
|
.line 279
|
|
:cond_0
|
|
invoke-virtual {v0}, Ljava/io/ByteArrayOutputStream;->toByteArray()[B
|
|
|
|
move-result-object p0
|
|
|
|
return-object p0
|
|
.end method
|