63 lines
2.6 KiB
Java
63 lines
2.6 KiB
Java
package com.kofax.kmc.ken.engines.gpu;
|
|
|
|
import android.graphics.Bitmap;
|
|
import com.kofax.kmc.ken.engines.data.DocumentDetectionSettings;
|
|
|
|
/* loaded from: classes3.dex */
|
|
public class BitmapGPUFrame extends com.kofax.mobile.sdk._internal.impl.detection.a implements GPUFrame {
|
|
private int _maxTextureSize;
|
|
private final com.kofax.mobile.sdk._internal.d fv;
|
|
|
|
public BitmapGPUFrame(Bitmap bitmap) {
|
|
super(bitmap);
|
|
this.fv = new com.kofax.mobile.sdk._internal.impl.f(new com.kofax.mobile.sdk._internal.impl.a());
|
|
this._maxTextureSize = 0;
|
|
}
|
|
|
|
@Override // com.kofax.kmc.ken.engines.gpu.GPUFrame
|
|
public float[] passTo(DocumentDetectionSettings documentDetectionSettings, GPUStrategyEdgeDetection gPUStrategyEdgeDetection) {
|
|
int width = this._bitmap.getWidth();
|
|
int height = this._bitmap.getHeight();
|
|
int max = Math.max(width, height);
|
|
int i = this._maxTextureSize;
|
|
if (max > i && i > 0) {
|
|
float f = i / max;
|
|
width = (int) (width * f);
|
|
height = (int) (height * f);
|
|
}
|
|
if (width % 2 != 0) {
|
|
width++;
|
|
}
|
|
if (height % 2 != 0) {
|
|
height++;
|
|
}
|
|
Bitmap createScaledBitmap = (width == this._bitmap.getWidth() && height == this._bitmap.getHeight()) ? null : Bitmap.createScaledBitmap(this._bitmap, width, height, false);
|
|
byte[] g = this.fv.g(createScaledBitmap != null ? createScaledBitmap : this._bitmap);
|
|
if (createScaledBitmap != null) {
|
|
createScaledBitmap.recycle();
|
|
}
|
|
float[] handleData = gPUStrategyEdgeDetection.handleData(g, width, height, documentDetectionSettings);
|
|
float width2 = this._bitmap.getWidth() / width;
|
|
float height2 = this._bitmap.getHeight() / height;
|
|
if (handleData == null) {
|
|
return null;
|
|
}
|
|
return new float[]{handleData[0] * width2, handleData[1] * height2, handleData[2] * width2, handleData[3] * height2, handleData[4] * width2, handleData[5] * height2, handleData[6] * width2, handleData[7] * height2};
|
|
}
|
|
|
|
@Override // com.kofax.mobile.sdk._internal.impl.detection.a, com.kofax.mobile.sdk._internal.impl.detection.Frame
|
|
public int getWidth() {
|
|
return this._bitmap.getWidth();
|
|
}
|
|
|
|
@Override // com.kofax.mobile.sdk._internal.impl.detection.a, com.kofax.mobile.sdk._internal.impl.detection.Frame
|
|
public int getHeight() {
|
|
return this._bitmap.getHeight();
|
|
}
|
|
|
|
@Override // com.kofax.kmc.ken.engines.gpu.GPUFrame
|
|
public void setMaxTextureSize(int i) {
|
|
this._maxTextureSize = i - 1;
|
|
}
|
|
}
|