what-the-bank/sources/com/kofax/mobile/sdk/_internal/impl/s.java

67 lines
2.7 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package com.kofax.mobile.sdk._internal.impl;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import com.kofax.kmc.ken.engines.data.Image;
import com.kofax.kmc.kut.utilities.error.ErrorInfo;
import com.kofax.kmc.kut.utilities.error.KmcException;
import com.kofax.kmc.kut.utilities.error.KmcRuntimeException;
import o.InterfaceC13391fZD;
/* loaded from: classes3.dex */
public class s implements com.kofax.mobile.sdk._internal.f {
@InterfaceC13391fZD
public s() {
}
@Override // com.kofax.mobile.sdk._internal.f
public Bitmap a(Image image, int i, int i2) throws KmcException {
if (image.getImageRepresentation() == Image.ImageRep.IMAGE_REP_NONE) {
throw new KmcRuntimeException(ErrorInfo.KMC_IP_NO_REPRESENTATION);
}
if (image.getImageFileRep() == Image.ImageFileRep.FILE_BUFFERED) {
throw new KmcRuntimeException(ErrorInfo.KMC_IP_FILE_AND_BUFFERED_REPRESENTATION);
}
return a(image, y(image), i, i2);
}
private Bitmap a(Image image, BitmapFactory.Options options, int i, int i2) throws KmcException {
int a = a(options, i, i2);
if (image.getImageRepresentation() == Image.ImageRep.IMAGE_REP_FILE && image.getImageFileRep() == Image.ImageFileRep.FILE_STORED) {
if (image.getImageMimeType() == Image.ImageMimeType.MIMETYPE_TIFF) {
Image image2 = new Image(image.getImageFilePath(), image.getImageMimeType());
image2.imageReadFromFile(1.0f / a);
return image2.getImageBitmap();
}
options.inJustDecodeBounds = false;
options.inSampleSize = a;
return BitmapFactory.decodeFile(image.getImageFilePath(), options);
}
return Bitmap.createScaledBitmap(image.getImageBitmap(), image.getImageBitmapWidth().intValue() / a, image.getImageBitmapHeight().intValue() / a, false);
}
private BitmapFactory.Options y(Image image) {
BitmapFactory.Options options = new BitmapFactory.Options();
if (image.getImageRepresentation() == Image.ImageRep.IMAGE_REP_FILE) {
options.outHeight = image.getImageFileHeight().intValue();
options.outWidth = image.getImageFileWidth().intValue();
} else {
options.outHeight = image.getImageBitmapHeight().intValue();
options.outWidth = image.getImageBitmapWidth().intValue();
}
return options;
}
public static int a(BitmapFactory.Options options, int i, int i2) {
int i3 = options.outHeight;
int i4 = options.outWidth;
int i5 = 1;
if (i3 > i2 || i4 > i) {
while (i3 / i5 > i2 && i4 / i5 > i) {
i5 <<= 1;
}
}
return i5;
}
}