51,408
社区成员
发帖
与我相关
我的任务
分享
public interface KfbLibrary extends Library {
// File libPath = new File("lib/ImageOperationLib.dll"); // windows
File libPath = new File("C:/soft/opt/ImageOperationLib.dll"); // linux
KfbLibrary INSTANCE = (KfbLibrary) Native.loadLibrary(libPath.getAbsolutePath(), KfbLibrary.class);
// File identification structure
class ImageInfoStruct extends Structure {
public int DataFilePTR;
@Override
protected List<String> getFieldOrder() {
return Arrays.asList("DataFilePTR");
}
public static class ByReference extends ImageInfoStruct implements Structure.ByReference {}
public static class ByValue extends ImageInfoStruct implements Structure.ByValue {}
}
int InitImageFileFunc(ImageInfoStruct.ByReference sImageInfo, String Path);
int UnInitImageFileFunc(ImageInfoStruct.ByReference sImageInfo);
Pointer GetImageStreamFunc(ImageInfoStruct.ByReference sImageInfo, float fScale, int nImagePosX, int nImagePosY, IntByReference nDataLength, PointerByReference ImageStream);
int GetHeaderInfoFunc(ImageInfoStruct.ByValue sImageInfo, IntByReference khiImageHeight, IntByReference khiImageWidth, IntByReference khiScanScale, FloatByReference khiSpendTime, DoubleByReference khiScanTime, FloatByReference khiImageCapRes, IntByReference khiImageBlockSize);
int GetImageDataRoiFunc(ImageInfoStruct.ByReference sImageInfo, float fScale, int sp_x, int sp_y, int nWidth, int nHeight, PointerByReference pBuffer, IntByReference DataLength, boolean flag);
int GetThumnailImageFunc(ImageInfoStruct.ByReference sImageInfo, PointerByReference ImageData, IntByReference nDataLength, IntByReference nThumbWidth, IntByReference nThumbHeight);
int GetThumnailImagePathFunc(String szFilePath, PointerByReference ImageData, IntByReference nDataLength, IntByReference nThumbWidth, IntByReference nThumbHeight);
int GetPriviewInfoFunc(ImageInfoStruct.ByReference sImageInfo, PointerByReference ImageData, IntByReference nDataLength, IntByReference nPriviewWidth, IntByReference nPriviewHeight);
int GetPriviewInfoPathFunc(String szFilePath, PointerByReference ImageData, IntByReference nDataLength, IntByReference nPriviewWidth, IntByReference nPriviewHeight);
int GetLableInfoFunc(ImageInfoStruct.ByReference sImageInfo, PointerByReference ImageData, IntByReference nDataLength, IntByReference nLabelWidth, IntByReference nLabelHeight);
int GetLableInfoPathFunc(String szFilePath, PointerByReference ImageData, IntByReference nDataLength, IntByReference nLabelWidth, IntByReference nLabelHeight);


private ImageInfoStruct.ByReference sImageInfo = new ImageInfoStruct.ByReference();
private ImageInfoStruct.ByValue sValue = new ImageInfoStruct.ByValue();
public void getHeaderInfo() {
IntByReference khiImageHeight = new IntByReference();
IntByReference khiImageWidth = new IntByReference();
IntByReference khiScanScale = new IntByReference();
FloatByReference khiSpendTime = new FloatByReference();
DoubleByReference khiScanTime = new DoubleByReference();
FloatByReference khiImageCapRes = new FloatByReference();
IntByReference khiImageBlockSize = new IntByReference();
int status = KfbLibrary.INSTANCE.GetHeaderInfoFunc(this.sValue, khiImageHeight, khiImageWidth, khiScanScale,
khiSpendTime, khiScanTime, khiImageCapRes, khiImageBlockSize);
if (status != 1) {
System.err.println("failed to get header info");
return;
}
this.width = khiImageWidth.getValue();
this.height = khiImageHeight.getValue();
this.capRes = khiImageCapRes.getValue();
/
}

