package com.ubtech.utils; import android.content.Context; import android.graphics.Bitmap; import android.os.Build; import android.renderscript.Allocation; import android.renderscript.Element; import android.renderscript.RenderScript; import android.renderscript.ScriptIntrinsicBlur; import android.util.Log; import com.ijm.dataencryption.de.DataDecryptTool; import java.lang.reflect.Array; /* loaded from: classes2.dex */ public class BlurHelper { private static BlurHelper e; private Context a; private Bitmap b; private int c; private float d = 0.125f; private BlurHelper(Context context) { this.a = context.getApplicationContext(); } public static synchronized BlurHelper a(Context context) { BlurHelper blurHelper; synchronized (BlurHelper.class) { if (e == null) { e = new BlurHelper(context); } blurHelper = e; } return blurHelper; } public BlurHelper a(Bitmap bitmap) { this.b = bitmap; return this; } public BlurHelper a(int i) { this.c = i; return this; } public BlurHelper a(float f) { this.d = f; return this; } public Bitmap a() { Bitmap bitmap = this.b; if (bitmap != null) { int i = this.c; if (i >= 1) { if (Build.VERSION.SDK_INT > 18) { return a(this.a, bitmap, this.d, i); } return a(bitmap, this.d, i); } throw new RuntimeException("radius must >=1"); } throw new RuntimeException("Bitmap can not be null"); } public static Bitmap a(Context context, Bitmap bitmap, float f, int i) { Bitmap createScaledBitmap = Bitmap.createScaledBitmap(bitmap, Math.round(bitmap.getWidth() * f), Math.round(bitmap.getHeight() * f), false); RenderScript create = RenderScript.create(context); create.setMessageHandler(new RenderScript.RSMessageHandler()); Allocation createFromBitmap = Allocation.createFromBitmap(create, bitmap, Allocation.MipmapControl.MIPMAP_NONE, 1); Allocation createTyped = Allocation.createTyped(create, createFromBitmap.getType()); ScriptIntrinsicBlur create2 = ScriptIntrinsicBlur.create(create, Element.U8_4(create)); create2.setInput(createFromBitmap); if (i <= 0) { i = 1; } if (i > 25) { i = 25; } create2.setRadius(i); create2.forEach(createTyped); createTyped.copyTo(createScaledBitmap); create2.destroy(); createTyped.destroy(); createFromBitmap.destroy(); create.destroy(); return createScaledBitmap; } public static Bitmap a(Bitmap bitmap, float f, int i) { int[] iArr; int i2 = i; Bitmap createScaledBitmap = Bitmap.createScaledBitmap(bitmap, Math.round(bitmap.getWidth() * f), Math.round(bitmap.getHeight() * f), false); Bitmap copy = createScaledBitmap.copy(createScaledBitmap.getConfig(), true); if (i2 < 1) { return null; } int width = copy.getWidth(); int height = copy.getHeight(); int i3 = width * height; int[] iArr2 = new int[i3]; Log.e("pix", width + " " + height + " " + iArr2.length); copy.getPixels(iArr2, 0, width, 0, 0, width, height); int i4 = width + (-1); int i5 = height + (-1); int i6 = i2 + i2 + 1; int[] iArr3 = new int[i3]; int[] iArr4 = new int[i3]; int[] iArr5 = new int[i3]; int[] iArr6 = new int[Math.max(width, height)]; int i7 = (i6 + 1) >> 1; int i8 = i7 * i7; int i9 = i8 * DataDecryptTool.DECRYPT_ALL_FILE; int[] iArr7 = new int[i9]; for (int i10 = 0; i10 < i9; i10++) { iArr7[i10] = i10 / i8; } int[][] iArr8 = (int[][]) Array.newInstance((Class) int.class, i6, 3); int i11 = i2 + 1; int i12 = 0; int i13 = 0; int i14 = 0; while (i12 < height) { Bitmap bitmap2 = copy; int i15 = -i2; int i16 = 0; int i17 = 0; int i18 = 0; int i19 = 0; int i20 = 0; int i21 = 0; int i22 = 0; int i23 = 0; int i24 = 0; while (i15 <= i2) { int i25 = i5; int i26 = height; int i27 = iArr2[i13 + Math.min(i4, Math.max(i15, 0))]; int[] iArr9 = iArr8[i15 + i2]; iArr9[0] = (i27 & 16711680) >> 16; iArr9[1] = (i27 & 65280) >> 8; iArr9[2] = i27 & 255; int abs = i11 - Math.abs(i15); i16 += iArr9[0] * abs; i17 += iArr9[1] * abs; i18 += iArr9[2] * abs; if (i15 > 0) { i22 += iArr9[0]; i23 += iArr9[1]; i24 += iArr9[2]; } else { i19 += iArr9[0]; i20 += iArr9[1]; i21 += iArr9[2]; } i15++; height = i26; i5 = i25; } int i28 = i5; int i29 = height; int i30 = i2; int i31 = 0; while (i31 < width) { iArr3[i13] = iArr7[i16]; iArr4[i13] = iArr7[i17]; iArr5[i13] = iArr7[i18]; int i32 = i16 - i19; int i33 = i17 - i20; int i34 = i18 - i21; int[] iArr10 = iArr8[((i30 - i2) + i6) % i6]; int i35 = i19 - iArr10[0]; int i36 = i20 - iArr10[1]; int i37 = i21 - iArr10[2]; if (i12 == 0) { iArr = iArr7; iArr6[i31] = Math.min(i31 + i2 + 1, i4); } else { iArr = iArr7; } int i38 = iArr2[i14 + iArr6[i31]]; iArr10[0] = (i38 & 16711680) >> 16; iArr10[1] = (i38 & 65280) >> 8; iArr10[2] = i38 & 255; int i39 = i22 + iArr10[0]; int i40 = i23 + iArr10[1]; int i41 = i24 + iArr10[2]; i16 = i32 + i39; i17 = i33 + i40; i18 = i34 + i41; i30 = (i30 + 1) % i6; int[] iArr11 = iArr8[i30 % i6]; i19 = i35 + iArr11[0]; i20 = i36 + iArr11[1]; i21 = i37 + iArr11[2]; i22 = i39 - iArr11[0]; i23 = i40 - iArr11[1]; i24 = i41 - iArr11[2]; i13++; i31++; iArr7 = iArr; } i14 += width; i12++; copy = bitmap2; height = i29; i5 = i28; } Bitmap bitmap3 = copy; int[] iArr12 = iArr7; int i42 = i5; int i43 = height; int i44 = 0; while (i44 < width) { int i45 = -i2; int i46 = i45 * width; int i47 = 0; int i48 = 0; int i49 = 0; int i50 = 0; int i51 = 0; int i52 = 0; int i53 = 0; int i54 = 0; int i55 = 0; while (i45 <= i2) { int[] iArr13 = iArr6; int max = Math.max(0, i46) + i44; int[] iArr14 = iArr8[i45 + i2]; iArr14[0] = iArr3[max]; iArr14[1] = iArr4[max]; iArr14[2] = iArr5[max]; int abs2 = i11 - Math.abs(i45); i47 += iArr3[max] * abs2; i48 += iArr4[max] * abs2; i49 += iArr5[max] * abs2; if (i45 > 0) { i53 += iArr14[0]; i54 += iArr14[1]; i55 += iArr14[2]; } else { i50 += iArr14[0]; i51 += iArr14[1]; i52 += iArr14[2]; } int i56 = i42; if (i45 < i56) { i46 += width; } i45++; i42 = i56; iArr6 = iArr13; } int[] iArr15 = iArr6; int i57 = i42; int i58 = i54; int i59 = i55; int i60 = i43; int i61 = 0; int i62 = i2; int i63 = i53; int i64 = i52; int i65 = i51; int i66 = i50; int i67 = i49; int i68 = i48; int i69 = i47; int i70 = i44; while (i61 < i60) { iArr2[i70] = (iArr2[i70] & (-16777216)) | (iArr12[i69] << 16) | (iArr12[i68] << 8) | iArr12[i67]; int i71 = i69 - i66; int i72 = i68 - i65; int i73 = i67 - i64; int[] iArr16 = iArr8[((i62 - i2) + i6) % i6]; int i74 = i66 - iArr16[0]; int i75 = i65 - iArr16[1]; int i76 = i64 - iArr16[2]; if (i44 == 0) { iArr15[i61] = Math.min(i61 + i11, i57) * width; } int i77 = iArr15[i61] + i44; iArr16[0] = iArr3[i77]; iArr16[1] = iArr4[i77]; iArr16[2] = iArr5[i77]; int i78 = i63 + iArr16[0]; int i79 = i58 + iArr16[1]; int i80 = i59 + iArr16[2]; i69 = i71 + i78; i68 = i72 + i79; i67 = i73 + i80; i62 = (i62 + 1) % i6; int[] iArr17 = iArr8[i62]; i66 = i74 + iArr17[0]; i65 = i75 + iArr17[1]; i64 = i76 + iArr17[2]; i63 = i78 - iArr17[0]; i58 = i79 - iArr17[1]; i59 = i80 - iArr17[2]; i70 += width; i61++; i2 = i; } i44++; i2 = i; i43 = i60; i42 = i57; iArr6 = iArr15; } int i81 = i43; Log.e("pix", width + " " + i81 + " " + iArr2.length); bitmap3.setPixels(iArr2, 0, width, 0, 0, width, i81); return bitmap3; } }