2020-05-17 12:40:10 +00:00
|
|
|
.class public final Lcom/discord/utilities/quantize/ColorUtils;
|
|
|
|
.super Ljava/lang/Object;
|
|
|
|
.source "ColorUtils.java"
|
|
|
|
|
|
|
|
|
|
|
|
# direct methods
|
|
|
|
.method public constructor <init>()V
|
|
|
|
.locals 0
|
|
|
|
|
|
|
|
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
|
|
|
|
|
|
|
|
return-void
|
|
|
|
.end method
|
|
|
|
|
|
|
|
.method public static HSLtoRGB([F)I
|
|
|
|
.locals 6
|
|
|
|
|
|
|
|
const/4 v0, 0x0
|
|
|
|
|
|
|
|
aget v1, p0, v0
|
|
|
|
|
|
|
|
const/4 v2, 0x1
|
|
|
|
|
|
|
|
aget v2, p0, v2
|
|
|
|
|
|
|
|
const/4 v3, 0x2
|
|
|
|
|
|
|
|
aget p0, p0, v3
|
|
|
|
|
|
|
|
const/high16 v3, 0x40000000 # 2.0f
|
|
|
|
|
|
|
|
mul-float v4, p0, v3
|
|
|
|
|
|
|
|
const/high16 v5, 0x3f800000 # 1.0f
|
|
|
|
|
|
|
|
sub-float/2addr v4, v5
|
|
|
|
|
|
|
|
invoke-static {v4}, Ljava/lang/Math;->abs(F)F
|
|
|
|
|
|
|
|
move-result v4
|
|
|
|
|
|
|
|
sub-float v4, v5, v4
|
|
|
|
|
|
|
|
mul-float v4, v4, v2
|
|
|
|
|
|
|
|
const/high16 v2, 0x3f000000 # 0.5f
|
|
|
|
|
|
|
|
mul-float v2, v2, v4
|
|
|
|
|
|
|
|
sub-float/2addr p0, v2
|
|
|
|
|
|
|
|
const/high16 v2, 0x42700000 # 60.0f
|
|
|
|
|
|
|
|
div-float v2, v1, v2
|
|
|
|
|
|
|
|
rem-float/2addr v2, v3
|
|
|
|
|
|
|
|
sub-float/2addr v2, v5
|
|
|
|
|
|
|
|
invoke-static {v2}, Ljava/lang/Math;->abs(F)F
|
|
|
|
|
|
|
|
move-result v2
|
|
|
|
|
|
|
|
sub-float/2addr v5, v2
|
|
|
|
|
|
|
|
mul-float v5, v5, v4
|
|
|
|
|
|
|
|
float-to-int v1, v1
|
|
|
|
|
|
|
|
div-int/lit8 v1, v1, 0x3c
|
|
|
|
|
|
|
|
const/high16 v2, 0x437f0000 # 255.0f
|
|
|
|
|
|
|
|
packed-switch v1, :pswitch_data_0
|
|
|
|
|
|
|
|
const/4 p0, 0x0
|
|
|
|
|
|
|
|
const/4 v1, 0x0
|
|
|
|
|
|
|
|
const/4 v3, 0x0
|
|
|
|
|
|
|
|
goto :goto_0
|
|
|
|
|
|
|
|
:pswitch_0
|
2020-07-08 16:44:49 +00:00
|
|
|
invoke-static {v4, p0, v2}, Lf/e/b/a/a;->b(FFF)I
|
2020-05-17 12:40:10 +00:00
|
|
|
|
|
|
|
move-result v1
|
|
|
|
|
|
|
|
mul-float v3, p0, v2
|
|
|
|
|
|
|
|
invoke-static {v3}, Ljava/lang/Math;->round(F)I
|
|
|
|
|
|
|
|
move-result v3
|
|
|
|
|
2020-07-08 16:44:49 +00:00
|
|
|
invoke-static {v5, p0, v2}, Lf/e/b/a/a;->b(FFF)I
|
2020-05-17 12:40:10 +00:00
|
|
|
|
|
|
|
move-result p0
|
|
|
|
|
|
|
|
goto :goto_0
|
|
|
|
|
|
|
|
:pswitch_1
|
2020-07-08 16:44:49 +00:00
|
|
|
invoke-static {v5, p0, v2}, Lf/e/b/a/a;->b(FFF)I
|
2020-05-17 12:40:10 +00:00
|
|
|
|
|
|
|
move-result v1
|
|
|
|
|
|
|
|
mul-float v3, p0, v2
|
|
|
|
|
|
|
|
invoke-static {v3}, Ljava/lang/Math;->round(F)I
|
|
|
|
|
|
|
|
move-result v3
|
|
|
|
|
2020-07-08 16:44:49 +00:00
|
|
|
invoke-static {v4, p0, v2}, Lf/e/b/a/a;->b(FFF)I
|
2020-05-17 12:40:10 +00:00
|
|
|
|
|
|
|
move-result p0
|
|
|
|
|
|
|
|
goto :goto_0
|
|
|
|
|
|
|
|
:pswitch_2
|
|
|
|
mul-float v1, p0, v2
|
|
|
|
|
|
|
|
invoke-static {v1}, Ljava/lang/Math;->round(F)I
|
|
|
|
|
|
|
|
move-result v1
|
|
|
|
|
2020-07-08 16:44:49 +00:00
|
|
|
invoke-static {v5, p0, v2}, Lf/e/b/a/a;->b(FFF)I
|
2020-05-17 12:40:10 +00:00
|
|
|
|
|
|
|
move-result v3
|
|
|
|
|
2020-07-08 16:44:49 +00:00
|
|
|
invoke-static {v4, p0, v2}, Lf/e/b/a/a;->b(FFF)I
|
2020-05-17 12:40:10 +00:00
|
|
|
|
|
|
|
move-result p0
|
|
|
|
|
|
|
|
goto :goto_0
|
|
|
|
|
|
|
|
:pswitch_3
|
|
|
|
mul-float v1, p0, v2
|
|
|
|
|
|
|
|
invoke-static {v1}, Ljava/lang/Math;->round(F)I
|
|
|
|
|
|
|
|
move-result v1
|
|
|
|
|
2020-07-08 16:44:49 +00:00
|
|
|
invoke-static {v4, p0, v2}, Lf/e/b/a/a;->b(FFF)I
|
2020-05-17 12:40:10 +00:00
|
|
|
|
|
|
|
move-result v3
|
|
|
|
|
2020-07-08 16:44:49 +00:00
|
|
|
invoke-static {v5, p0, v2}, Lf/e/b/a/a;->b(FFF)I
|
2020-05-17 12:40:10 +00:00
|
|
|
|
|
|
|
move-result p0
|
|
|
|
|
|
|
|
goto :goto_0
|
|
|
|
|
|
|
|
:pswitch_4
|
2020-07-08 16:44:49 +00:00
|
|
|
invoke-static {v5, p0, v2}, Lf/e/b/a/a;->b(FFF)I
|
2020-05-17 12:40:10 +00:00
|
|
|
|
|
|
|
move-result v1
|
|
|
|
|
2020-07-08 16:44:49 +00:00
|
|
|
invoke-static {v4, p0, v2}, Lf/e/b/a/a;->b(FFF)I
|
2020-05-17 12:40:10 +00:00
|
|
|
|
|
|
|
move-result v3
|
|
|
|
|
|
|
|
mul-float p0, p0, v2
|
|
|
|
|
|
|
|
invoke-static {p0}, Ljava/lang/Math;->round(F)I
|
|
|
|
|
|
|
|
move-result p0
|
|
|
|
|
|
|
|
goto :goto_0
|
|
|
|
|
|
|
|
:pswitch_5
|
2020-07-08 16:44:49 +00:00
|
|
|
invoke-static {v4, p0, v2}, Lf/e/b/a/a;->b(FFF)I
|
2020-05-17 12:40:10 +00:00
|
|
|
|
|
|
|
move-result v1
|
|
|
|
|
2020-07-08 16:44:49 +00:00
|
|
|
invoke-static {v5, p0, v2}, Lf/e/b/a/a;->b(FFF)I
|
2020-05-17 12:40:10 +00:00
|
|
|
|
|
|
|
move-result v3
|
|
|
|
|
|
|
|
mul-float p0, p0, v2
|
|
|
|
|
|
|
|
invoke-static {p0}, Ljava/lang/Math;->round(F)I
|
|
|
|
|
|
|
|
move-result p0
|
|
|
|
|
|
|
|
:goto_0
|
|
|
|
const/16 v2, 0xff
|
|
|
|
|
|
|
|
invoke-static {v2, v1}, Ljava/lang/Math;->min(II)I
|
|
|
|
|
|
|
|
move-result v1
|
|
|
|
|
|
|
|
invoke-static {v0, v1}, Ljava/lang/Math;->max(II)I
|
|
|
|
|
|
|
|
move-result v1
|
|
|
|
|
|
|
|
invoke-static {v2, v3}, Ljava/lang/Math;->min(II)I
|
|
|
|
|
|
|
|
move-result v3
|
|
|
|
|
|
|
|
invoke-static {v0, v3}, Ljava/lang/Math;->max(II)I
|
|
|
|
|
|
|
|
move-result v3
|
|
|
|
|
|
|
|
invoke-static {v2, p0}, Ljava/lang/Math;->min(II)I
|
|
|
|
|
|
|
|
move-result p0
|
|
|
|
|
|
|
|
invoke-static {v0, p0}, Ljava/lang/Math;->max(II)I
|
|
|
|
|
|
|
|
move-result p0
|
|
|
|
|
|
|
|
invoke-static {v1, v3, p0}, Landroid/graphics/Color;->rgb(III)I
|
|
|
|
|
|
|
|
move-result p0
|
|
|
|
|
|
|
|
return p0
|
|
|
|
|
|
|
|
:pswitch_data_0
|
|
|
|
.packed-switch 0x0
|
|
|
|
:pswitch_5
|
|
|
|
:pswitch_4
|
|
|
|
:pswitch_3
|
|
|
|
:pswitch_2
|
|
|
|
:pswitch_1
|
|
|
|
:pswitch_0
|
|
|
|
:pswitch_0
|
|
|
|
.end packed-switch
|
|
|
|
.end method
|
|
|
|
|
|
|
|
.method public static RGBtoHSL(III[F)V
|
|
|
|
.locals 5
|
|
|
|
|
|
|
|
int-to-float p0, p0
|
|
|
|
|
|
|
|
const/high16 v0, 0x437f0000 # 255.0f
|
|
|
|
|
|
|
|
div-float/2addr p0, v0
|
|
|
|
|
|
|
|
int-to-float p1, p1
|
|
|
|
|
|
|
|
div-float/2addr p1, v0
|
|
|
|
|
|
|
|
int-to-float p2, p2
|
|
|
|
|
|
|
|
div-float/2addr p2, v0
|
|
|
|
|
|
|
|
invoke-static {p1, p2}, Ljava/lang/Math;->max(FF)F
|
|
|
|
|
|
|
|
move-result v0
|
|
|
|
|
|
|
|
invoke-static {p0, v0}, Ljava/lang/Math;->max(FF)F
|
|
|
|
|
|
|
|
move-result v0
|
|
|
|
|
|
|
|
invoke-static {p1, p2}, Ljava/lang/Math;->min(FF)F
|
|
|
|
|
|
|
|
move-result v1
|
|
|
|
|
|
|
|
invoke-static {p0, v1}, Ljava/lang/Math;->min(FF)F
|
|
|
|
|
|
|
|
move-result v1
|
|
|
|
|
|
|
|
sub-float v2, v0, v1
|
|
|
|
|
|
|
|
add-float v3, v0, v1
|
|
|
|
|
|
|
|
const/high16 v4, 0x40000000 # 2.0f
|
|
|
|
|
|
|
|
div-float/2addr v3, v4
|
|
|
|
|
|
|
|
cmpl-float v1, v0, v1
|
|
|
|
|
|
|
|
if-nez v1, :cond_0
|
|
|
|
|
|
|
|
const/4 p0, 0x0
|
|
|
|
|
|
|
|
const/4 p1, 0x0
|
|
|
|
|
|
|
|
goto :goto_1
|
|
|
|
|
|
|
|
:cond_0
|
|
|
|
cmpl-float v1, v0, p0
|
|
|
|
|
|
|
|
if-nez v1, :cond_1
|
|
|
|
|
|
|
|
sub-float/2addr p1, p2
|
|
|
|
|
|
|
|
div-float/2addr p1, v2
|
|
|
|
|
|
|
|
const/high16 p0, 0x40c00000 # 6.0f
|
|
|
|
|
|
|
|
rem-float/2addr p1, p0
|
|
|
|
|
|
|
|
move p0, p1
|
|
|
|
|
|
|
|
goto :goto_0
|
|
|
|
|
|
|
|
:cond_1
|
|
|
|
cmpl-float v0, v0, p1
|
|
|
|
|
|
|
|
if-nez v0, :cond_2
|
|
|
|
|
|
|
|
sub-float/2addr p2, p0
|
|
|
|
|
|
|
|
div-float/2addr p2, v2
|
|
|
|
|
|
|
|
add-float/2addr p2, v4
|
|
|
|
|
|
|
|
move p0, p2
|
|
|
|
|
|
|
|
goto :goto_0
|
|
|
|
|
|
|
|
:cond_2
|
|
|
|
sub-float/2addr p0, p1
|
|
|
|
|
|
|
|
div-float/2addr p0, v2
|
|
|
|
|
|
|
|
const/high16 p1, 0x40800000 # 4.0f
|
|
|
|
|
|
|
|
add-float/2addr p0, p1
|
|
|
|
|
|
|
|
:goto_0
|
|
|
|
mul-float v4, v4, v3
|
|
|
|
|
|
|
|
const/high16 p1, 0x3f800000 # 1.0f
|
|
|
|
|
|
|
|
sub-float/2addr v4, p1
|
|
|
|
|
|
|
|
invoke-static {v4}, Ljava/lang/Math;->abs(F)F
|
|
|
|
|
|
|
|
move-result p2
|
|
|
|
|
|
|
|
sub-float/2addr p1, p2
|
|
|
|
|
|
|
|
div-float p1, v2, p1
|
|
|
|
|
|
|
|
:goto_1
|
|
|
|
const/4 p2, 0x0
|
|
|
|
|
|
|
|
const/high16 v0, 0x42700000 # 60.0f
|
|
|
|
|
|
|
|
mul-float p0, p0, v0
|
|
|
|
|
|
|
|
const/high16 v0, 0x43b40000 # 360.0f
|
|
|
|
|
|
|
|
rem-float/2addr p0, v0
|
|
|
|
|
|
|
|
aput p0, p3, p2
|
|
|
|
|
|
|
|
const/4 p0, 0x1
|
|
|
|
|
|
|
|
aput p1, p3, p0
|
|
|
|
|
|
|
|
const/4 p0, 0x2
|
|
|
|
|
|
|
|
aput v3, p3, p0
|
|
|
|
|
|
|
|
return-void
|
|
|
|
.end method
|
|
|
|
|
|
|
|
.method public static calculateContrast(II)F
|
|
|
|
.locals 0
|
|
|
|
|
|
|
|
invoke-static {p0}, Lcom/discord/utilities/quantize/ColorUtils;->calculateXyzLuma(I)F
|
|
|
|
|
|
|
|
move-result p0
|
|
|
|
|
|
|
|
invoke-static {p1}, Lcom/discord/utilities/quantize/ColorUtils;->calculateXyzLuma(I)F
|
|
|
|
|
|
|
|
move-result p1
|
|
|
|
|
|
|
|
sub-float/2addr p0, p1
|
|
|
|
|
|
|
|
invoke-static {p0}, Ljava/lang/Math;->abs(F)F
|
|
|
|
|
|
|
|
move-result p0
|
|
|
|
|
|
|
|
return p0
|
|
|
|
.end method
|
|
|
|
|
|
|
|
.method public static calculateXyzLuma(I)F
|
|
|
|
.locals 3
|
|
|
|
|
|
|
|
invoke-static {p0}, Landroid/graphics/Color;->red(I)I
|
|
|
|
|
|
|
|
move-result v0
|
|
|
|
|
|
|
|
int-to-float v0, v0
|
|
|
|
|
|
|
|
const v1, 0x3e59b3d0 # 0.2126f
|
|
|
|
|
|
|
|
mul-float v0, v0, v1
|
|
|
|
|
|
|
|
invoke-static {p0}, Landroid/graphics/Color;->green(I)I
|
|
|
|
|
|
|
|
move-result v1
|
|
|
|
|
|
|
|
int-to-float v1, v1
|
|
|
|
|
|
|
|
const v2, 0x3f371759 # 0.7152f
|
|
|
|
|
|
|
|
mul-float v1, v1, v2
|
|
|
|
|
|
|
|
add-float/2addr v1, v0
|
|
|
|
|
|
|
|
invoke-static {p0}, Landroid/graphics/Color;->blue(I)I
|
|
|
|
|
|
|
|
move-result p0
|
|
|
|
|
|
|
|
int-to-float p0, p0
|
|
|
|
|
|
|
|
const v0, 0x3d93dd98 # 0.0722f
|
|
|
|
|
|
|
|
mul-float p0, p0, v0
|
|
|
|
|
|
|
|
add-float/2addr p0, v1
|
|
|
|
|
|
|
|
const/high16 v0, 0x437f0000 # 255.0f
|
|
|
|
|
|
|
|
div-float/2addr p0, v0
|
|
|
|
|
|
|
|
return p0
|
|
|
|
.end method
|