正在查看: Telegram v11.13.0 应用的 Bitmaps.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Telegram v11.13.0 应用的 Bitmaps.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package org.telegram.messenger;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.RectF;
import android.os.Build;
public class Bitmaps {
private static volatile Matrix sScaleMatrix;
private static final ThreadLocal<byte[]> jpegData = new ThreadLocal<byte[]>() {
@Override
public byte[] initialValue() {
return new byte[]{-1, -40, -1, -37, 0, 67, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -64, 0, 17, 8, 0, 0, 0, 0, 3, 1, 34, 0, 2, 17, 0, 3, 17, 0, -1, -60, 0, 31, 0, 0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, -1, -60, 0, -75, 16, 0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1, 125, 1, 2, 3, 0, 4, 17, 5, 18, 33, 49, 65, 6, 19, 81, 97, 7, 34, 113, 20, 50, -127, -111, -95, 8, 35, 66, -79, -63, 21, 82, -47, -16, 36, 51, 98, 114, -126, 9, 10, 22, 23, 24, 25, 26, 37, 38, 39, 40, 41, 42, 52, 53, 54, 55, 56, 57, 58, 67, 68, 69, 70, 71, 72, 73, 74, 83, 84, 85, 86, 87, 88, 89, 90, 99, 100, 101, 102, 103, 104, 105, 106, 115, 116, 117, 118, 119, 120, 121, 122, -125, -124, -123, -122, -121, -120, -119, -118, -110, -109, -108, -107, -106, -105, -104, -103, -102, -94, -93, -92, -91, -90, -89, -88, -87, -86, -78, -77, -76, -75, -74, -73, -72, -71, -70, -62, -61, -60, -59, -58, -57, -56, -55, -54, -46, -45, -44, -43, -42, -41, -40, -39, -38, -31, -30, -29, -28, -27, -26, -25, -24, -23, -22, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -1, -60, 0, 31, 1, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, -1, -60, 0, -75, 17, 0, 2, 1, 2, 4, 4, 3, 4, 7, 5, 4, 4, 0, 1, 2, 119, 0, 1, 2, 3, 17, 4, 5, 33, 49, 6, 18, 65, 81, 7, 97, 113, 19, 34, 50, -127, 8, 20, 66, -111, -95, -79, -63, 9, 35, 51, 82, -16, 21, 98, 114, -47, 10, 22, 36, 52, -31, 37, -15, 23, 24, 25, 26, 38, 39, 40, 41, 42, 53, 54, 55, 56, 57, 58, 67, 68, 69, 70, 71, 72, 73, 74, 83, 84, 85, 86, 87, 88, 89, 90, 99, 100, 101, 102, 103, 104, 105, 106, 115, 116, 117, 118, 119, 120, 121, 122, -126, -125, -124, -123, -122, -121, -120, -119, -118, -110, -109, -108, -107, -106, -105, -104, -103, -102, -94, -93, -92, -91, -90, -89, -88, -87, -86, -78, -77, -76, -75, -74, -73, -72, -71, -70, -62, -61, -60, -59, -58, -57, -56, -55, -54, -46, -45, -44, -43, -42, -41, -40, -39, -38, -30, -29, -28, -27, -26, -25, -24, -23, -22, -14, -13, -12, -11, -10, -9, -8, -7, -6, -1, -38, 0, 12, 3, 1, 0, 2, 17, 3, 17, 0, 63, 0, -114, -118, 40, -96, 15, -1, -39};
}
};
protected static byte[] header = {-1, -40, -1, -32, 0, 16, 74, 70, 73, 70, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, -1, -37, 0, 67, 0, 40, 28, 30, 35, 30, 25, 40, 35, 33, 35, 45, 43, 40, 48, 60, 100, 65, 60, 55, 55, 60, 123, 88, 93, 73, 100, -111, Byte.MIN_VALUE, -103, -106, -113, Byte.MIN_VALUE, -116, -118, -96, -76, -26, -61, -96, -86, -38, -83, -118, -116, -56, -1, -53, -38, -18, -11, -1, -1, -1, -101, -63, -1, -1, -1, -6, -1, -26, -3, -1, -8, -1, -37, 0, 67, 1, 43, 45, 45, 60, 53, 60, 118, 65, 65, 118, -8, -91, -116, -91, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -1, -64, 0, 17, 8, 0, 30, 0, 40, 3, 1, 34, 0, 2, 17, 1, 3, 17, 1, -1, -60, 0, 31, 0, 0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, -1, -60, 0, -75, 16, 0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1, 125, 1, 2, 3, 0, 4, 17, 5, 18, 33, 49, 65, 6, 19, 81, 97, 7, 34, 113, 20, 50, -127, -111, -95, 8, 35, 66, -79, -63, 21, 82, -47, -16, 36, 51, 98, 114, -126, 9, 10, 22, 23, 24, 25, 26, 37, 38, 39, 40, 41, 42, 52, 53, 54, 55, 56, 57, 58, 67, 68, 69, 70, 71, 72, 73, 74, 83, 84, 85, 86, 87, 88, 89, 90, 99, 100, 101, 102, 103, 104, 105, 106, 115, 116, 117, 118, 119, 120, 121, 122, -125, -124, -123, -122, -121, -120, -119, -118, -110, -109, -108, -107, -106, -105, -104, -103, -102, -94, -93, -92, -91, -90, -89, -88, -87, -86, -78, -77, -76, -75, -74, -73, -72, -71, -70, -62, -61, -60, -59, -58, -57, -56, -55, -54, -46, -45, -44, -43, -42, -41, -40, -39, -38, -31, -30, -29, -28, -27, -26, -25, -24, -23, -22, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -1, -60, 0, 31, 1, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, -1, -60, 0, -75, 17, 0, 2, 1, 2, 4, 4, 3, 4, 7, 5, 4, 4, 0, 1, 2, 119, 0, 1, 2, 3, 17, 4, 5, 33, 49, 6, 18, 65, 81, 7, 97, 113, 19, 34, 50, -127, 8, 20, 66, -111, -95, -79, -63, 9, 35, 51, 82, -16, 21, 98, 114, -47, 10, 22, 36, 52, -31, 37, -15, 23, 24, 25, 26, 38, 39, 40, 41, 42, 53, 54, 55, 56, 57, 58, 67, 68, 69, 70, 71, 72, 73, 74, 83, 84, 85, 86, 87, 88, 89, 90, 99, 100, 101, 102, 103, 104, 105, 106, 115, 116, 117, 118, 119, 120, 121, 122, -126, -125, -124, -123, -122, -121, -120, -119, -118, -110, -109, -108, -107, -106, -105, -104, -103, -102, -94, -93, -92, -91, -90, -89, -88, -87, -86, -78, -77, -76, -75, -74, -73, -72, -71, -70, -62, -61, -60, -59, -58, -57, -56, -55, -54, -46, -45, -44, -43, -42, -41, -40, -39, -38, -30, -29, -28, -27, -26, -25, -24, -23, -22, -14, -13, -12, -11, -10, -9, -8, -7, -6, -1, -38, 0, 12, 3, 1, 0, 2, 17, 3, 17, 0, 63, 0};
protected static byte[] footer = {-1, -39};
static class AnonymousClass2 {
static final int[] $SwitchMap$android$graphics$Bitmap$Config;
static {
int[] iArr = new int[Bitmap.Config.values().length];
$SwitchMap$android$graphics$Bitmap$Config = iArr;
try {
iArr[Bitmap.Config.RGB_565.ordinal()] = 1;
} catch (NoSuchFieldError unused) {
}
try {
$SwitchMap$android$graphics$Bitmap$Config[Bitmap.Config.ALPHA_8.ordinal()] = 2;
} catch (NoSuchFieldError unused2) {
}
try {
$SwitchMap$android$graphics$Bitmap$Config[Bitmap.Config.ARGB_4444.ordinal()] = 3;
} catch (NoSuchFieldError unused3) {
}
try {
$SwitchMap$android$graphics$Bitmap$Config[Bitmap.Config.ARGB_8888.ordinal()] = 4;
} catch (NoSuchFieldError unused4) {
}
}
}
private static void checkWidthHeight(int i, int i2) {
if (i <= 0) {
throw new IllegalArgumentException("width must be > 0");
}
if (i2 <= 0) {
throw new IllegalArgumentException("height must be > 0");
}
}
private static void checkXYSign(int i, int i2) {
if (i < 0) {
throw new IllegalArgumentException("x must be >= 0");
}
if (i2 < 0) {
throw new IllegalArgumentException("y must be >= 0");
}
}
public static Bitmap createBitmap(int i, int i2, Bitmap.Config config) {
Bitmap createBitmap;
if (Build.VERSION.SDK_INT < 21) {
BitmapFactory.Options options = new BitmapFactory.Options();
options.inDither = true;
options.inPreferredConfig = config;
options.inPurgeable = true;
options.inSampleSize = 1;
options.inMutable = true;
byte[] bArr = jpegData.get();
bArr[76] = (byte) (i2 >> 8);
bArr[77] = (byte) (i2 & NotificationCenter.reloadInterface);
bArr[78] = (byte) (i >> 8);
bArr[79] = (byte) (i & NotificationCenter.reloadInterface);
createBitmap = BitmapFactory.decodeByteArray(bArr, 0, bArr.length, options);
Utilities.pinBitmap(createBitmap);
createBitmap.setHasAlpha(true);
createBitmap.eraseColor(0);
} else {
createBitmap = Bitmap.createBitmap(i, i2, config);
}
if (config == Bitmap.Config.ARGB_8888 || config == Bitmap.Config.ARGB_4444) {
createBitmap.eraseColor(0);
}
return createBitmap;
}
public static Bitmap createBitmap(Bitmap bitmap, int i, int i2, int i3, int i4) {
return createBitmap(bitmap, i, i2, i3, i4, null, false);
}
public static Bitmap createBitmap(Bitmap bitmap, int i, int i2, int i3, int i4, Matrix matrix, boolean z) {
Bitmap createBitmap;
Paint paint;
int i5;
if (Build.VERSION.SDK_INT >= 21) {
return Bitmap.createBitmap(bitmap, i, i2, i3, i4, matrix, z);
}
checkXYSign(i, i2);
checkWidthHeight(i3, i4);
int i6 = i + i3;
if (i6 > bitmap.getWidth()) {
throw new IllegalArgumentException("x + width must be <= bitmap.width()");
}
int i7 = i2 + i4;
if (i7 > bitmap.getHeight()) {
throw new IllegalArgumentException("y + height must be <= bitmap.height()");
}
if (!bitmap.isMutable() && i == 0 && i2 == 0 && i3 == bitmap.getWidth() && i4 == bitmap.getHeight() && (matrix == null || matrix.isIdentity())) {
return bitmap;
}
Canvas canvas = new Canvas();
Rect rect = new Rect(i, i2, i6, i7);
RectF rectF = new RectF(0.0f, 0.0f, i3, i4);
Bitmap.Config config = Bitmap.Config.ARGB_8888;
Bitmap.Config config2 = bitmap.getConfig();
Bitmap.Config config3 = (config2 == null || (i5 = AnonymousClass2.$SwitchMap$android$graphics$Bitmap$Config[config2.ordinal()]) == 1 || i5 != 2) ? config : Bitmap.Config.ALPHA_8;
if (matrix == null || matrix.isIdentity()) {
createBitmap = createBitmap(i3, i4, config3);
paint = null;
} else {
boolean z2 = !matrix.rectStaysRect();
RectF rectF2 = new RectF();
matrix.mapRect(rectF2, rectF);
int round = Math.round(rectF2.width());
int round2 = Math.round(rectF2.height());
if (!z2) {
config = config3;
}
createBitmap = createBitmap(round, round2, config);
canvas.translate(-rectF2.left, -rectF2.top);
canvas.concat(matrix);
paint = new Paint();
paint.setFilterBitmap(z);
if (z2) {
paint.setAntiAlias(true);
}
}
createBitmap.setDensity(bitmap.getDensity());
createBitmap.setHasAlpha(bitmap.hasAlpha());
createBitmap.setPremultiplied(bitmap.isPremultiplied());
canvas.setBitmap(createBitmap);
canvas.drawBitmap(bitmap, rect, rectF, paint);
try {
canvas.setBitmap(null);
} catch (Exception unused) {
}
return createBitmap;
}
public static Bitmap createScaledBitmap(Bitmap bitmap, int i, int i2, boolean z) {
Matrix matrix;
if (Build.VERSION.SDK_INT >= 21) {
return Bitmap.createScaledBitmap(bitmap, i, i2, z);
}
synchronized (Bitmap.class) {
matrix = sScaleMatrix;
sScaleMatrix = null;
}
if (matrix == null) {
matrix = new Matrix();
}
int width = bitmap.getWidth();
int height = bitmap.getHeight();
matrix.setScale(i / width, i2 / height);
Bitmap createBitmap = createBitmap(bitmap, 0, 0, width, height, matrix, z);
synchronized (Bitmap.class) {
try {
if (sScaleMatrix == null) {
sScaleMatrix = matrix;
}
} catch (Throwable th) {
throw th;
}
}
return createBitmap;
}
}