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

83 lines
2.9 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package com.kofax.mobile.sdk._internal.impl;
import com.kofax.kmc.ken.engines.data.Image;
import com.kofax.kmc.kut.utilities.error.KmcException;
import com.kofax.mobile.sdk._internal.IImageToByteArray;
import com.kofax.mobile.sdk._internal.g;
import java.nio.ByteBuffer;
import o.InterfaceC13391fZD;
/* loaded from: classes3.dex */
public class w implements IImageToByteArray {
private static final String TAG = "w";
private final com.kofax.mobile.sdk._internal.g wM;
@InterfaceC13391fZD
public w(com.kofax.mobile.sdk._internal.g gVar) {
this.wM = gVar;
}
@Override // com.kofax.mobile.sdk._internal.IImageToByteArray
public byte[] convert(Image image) {
if (image.getImageFileRep() == Image.ImageFileRep.FILE_BUFFERED) {
return A(image);
}
g.a aVar = null;
try {
aVar = this.wM.w(image);
Image image2 = new Image(aVar.getBitmap());
image2.setImageMimeType(image.getImageMimeType());
image2.setImageOutputColor(image.getImageOutputColor());
image2.setImageJpegQuality(image.getImageJpegQuality().intValue());
if (image.getImageDPI() != null) {
image2.setImageDPI(image.getImageDPI().intValue());
}
return z(image2);
} finally {
if (aVar != null) {
aVar.be();
}
}
}
private byte[] z(Image image) {
if (image.getImageBitmap() == null) {
throw new IllegalArgumentException("image doesn't have a bitmap");
}
try {
if (image.getImageFileRep() != Image.ImageFileRep.FILE_NONE) {
throw new IllegalArgumentException("Cannot convert an image that has a file representation");
}
try {
image.imageWriteToFileBuffer();
byte[] A = A(image);
try {
image.imageClearFileBuffer();
} catch (KmcException e) {
com.kofax.mobile.sdk._internal.k.e(TAG, "Unable to clear a file buffer", (Throwable) e);
}
return A;
} catch (KmcException e2) {
throw new RuntimeException(e2);
}
} catch (Throwable th) {
try {
image.imageClearFileBuffer();
} catch (KmcException e3) {
com.kofax.mobile.sdk._internal.k.e(TAG, "Unable to clear a file buffer", (Throwable) e3);
}
throw th;
}
}
private byte[] A(Image image) {
if (image.getImageFileRep() != Image.ImageFileRep.FILE_BUFFERED) {
throw new IllegalArgumentException("image doesn't have a file buffer");
}
ByteBuffer imageFileBuffer = image.getImageFileBuffer();
byte[] bArr = new byte[imageFileBuffer.capacity()];
imageFileBuffer.get(bArr);
return bArr;
}
}