#pragma once
#include "barcodeImage.h"
#define K120_HANDLE HANDLE
int WINAPI setImage(K120_HANDLE hnd, unsigned char *pImage, int len, int imgType);
// public int setImage(Pointer hnd, ByteBuffer pImage, int len, int format);
// public int setImagePointer hnd, ByteByReference pImage, int len, int format);
// public NativeLong setImage(Pointer hnd, Pointer pImage, long len, long format);
// public NativeLong setImage(Pointer hnd, byte[] pImage, long len, long format);
public int setImage(Pointer hnd, Pointer pImage, int len, int format);java.lang.Error: Invalid memory access
at com.sun.jna.Native.invokeInt(Native Method)
at com.sun.jna.Function.invoke(Function.java:390)
at com.sun.jna.Function.invoke(Function.java:323)
at com.sun.jna.Library$Handler.invoke(Library.java:236)PointerByReference ptrRef = new PointerByReference();
Pointer ptrImage;
byte byteImage[];
int nRet = TestJna.INSTANCE.initialise(ptrRef.getPointer());
byteImage = fileToByte("sample.bmp");
ptrImage = new Memory(byteImage.length);
ptrImage.write(0, byteImage, 0, byteImage.length);
nRet = TestJna.INSTANCE.setImage(ptrRef.getPointer(), ptrImage, byteImage.length, 1);public interface TestJna extends StdCallLibrary {
public static final TestJna INSTANCE = (TestJna) Native.loadLibrary("TestJna", TestJna.class);
public int initialise(Pointer pQtf);
public int setImage(Pointer hnd, Pointer pImage, int len, int format);
}int WINAPI initialise(K120_HANDLE *hnd);
Description:
Initialize environment before any function call.
Arguments:
Name I/O Description
hnd output handle
int WINAPI setImage(K120_HANDLE hnd, unsigned char *pImage, int len, int imgType);
Description:
Input image which will be analysed.
Arguments:
Name Description
hnd handle returned by initialise funciton
pImage image buffer pointer
len image buffer length
imgType image format