65 lines
2.7 KiB
Java
65 lines
2.7 KiB
Java
|
package o;
|
||
|
|
||
|
import android.graphics.Bitmap;
|
||
|
import android.graphics.Canvas;
|
||
|
import android.view.View;
|
||
|
import android.view.ViewGroup;
|
||
|
import org.bouncycastle.asn1.cmp.PKIFailureInfo;
|
||
|
|
||
|
/* renamed from: o.fLx, reason: case insensitive filesystem */
|
||
|
/* loaded from: classes5.dex */
|
||
|
public final class C12946fLx {
|
||
|
public static Bitmap aAB_(View view, int i, int i2) {
|
||
|
int makeMeasureSpec;
|
||
|
int makeMeasureSpec2;
|
||
|
ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
|
||
|
if (layoutParams == null) {
|
||
|
return null;
|
||
|
}
|
||
|
int i3 = layoutParams.width;
|
||
|
if (i3 == -2) {
|
||
|
makeMeasureSpec = View.MeasureSpec.makeMeasureSpec(i, PKIFailureInfo.systemUnavail);
|
||
|
} else if (i3 == -1) {
|
||
|
makeMeasureSpec = View.MeasureSpec.makeMeasureSpec(i, 1073741824);
|
||
|
} else {
|
||
|
makeMeasureSpec = View.MeasureSpec.makeMeasureSpec(i3, 1073741824);
|
||
|
}
|
||
|
int i4 = layoutParams.height;
|
||
|
if (i4 == -2) {
|
||
|
makeMeasureSpec2 = View.MeasureSpec.makeMeasureSpec(i2, PKIFailureInfo.systemUnavail);
|
||
|
} else if (i4 == -1) {
|
||
|
makeMeasureSpec2 = View.MeasureSpec.makeMeasureSpec(i2, 1073741824);
|
||
|
} else {
|
||
|
makeMeasureSpec2 = View.MeasureSpec.makeMeasureSpec(i4, 1073741824);
|
||
|
}
|
||
|
view.measure(makeMeasureSpec, makeMeasureSpec2);
|
||
|
int measuredWidth = view.getMeasuredWidth();
|
||
|
int measuredHeight = view.getMeasuredHeight();
|
||
|
if (measuredWidth != 0 && measuredHeight != 0) {
|
||
|
view.layout(0, 0, measuredWidth, measuredHeight);
|
||
|
int width = view.getWidth();
|
||
|
int height = view.getHeight();
|
||
|
view.measure(View.MeasureSpec.makeMeasureSpec(width, 1073741824), View.MeasureSpec.makeMeasureSpec(height, 1073741824));
|
||
|
view.layout(0, 0, view.getMeasuredWidth(), view.getMeasuredHeight());
|
||
|
view.setDrawingCacheEnabled(true);
|
||
|
try {
|
||
|
Bitmap drawingCache = view.getDrawingCache(true);
|
||
|
if (drawingCache != null) {
|
||
|
Bitmap createScaledBitmap = Bitmap.createScaledBitmap(drawingCache, width, height, true);
|
||
|
view.setDrawingCacheEnabled(false);
|
||
|
return createScaledBitmap;
|
||
|
}
|
||
|
Bitmap createBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565);
|
||
|
view.draw(new Canvas(createBitmap));
|
||
|
return createBitmap;
|
||
|
} catch (Exception unused) {
|
||
|
guQ.a("Bitmap throws exception", new Object[0]);
|
||
|
return null;
|
||
|
} catch (OutOfMemoryError unused2) {
|
||
|
guQ.a("Bitmap Out of memory error", new Object[0]);
|
||
|
}
|
||
|
}
|
||
|
return null;
|
||
|
}
|
||
|
}
|