Hello all...
I've been working on trying to access a linux shared object from java for
the last two weeks. Its my first time using JNA, and its been a reletively
good experience. I believe that once I've solved this final problem, I will
have completed the task I'm trying to do. As things are becoming quite
urgent I would greatly appreciate a timely response.
*This is the structure I'm having problems with: *
typedef struct
{
...
/** Pointer to the first scan line of the image. In case of planar
format it is a
pointer to an array of pointers to separate planes. */
void* Data;
...
} RE_IMAGE;
*
I've coded this as follows:*
public interface RedEye extends Library {
public static class RE_IMAGE extends Structure {
...
public Pointer data;
...
}
}
*
And I'm using it like this:*
RedEye.RE_IMAGE reImage = new RedEye.RE_IMAGE();
...
//We have to pass in a pointer to the data...
ByteArrayOutputStream byteArrayOutputStream = new
ByteArrayOutputStream();
ImageIO.write(image_input, "jpg", byteArrayOutputStream);
byte[] bytes = byteArrayOutputStream.toByteArray();
ByteBuffer byteBuffer = ByteBuffer.wrap(bytes);
Buffer buffer = (Buffer) byteBuffer;
reImage.data = Native.getDirectBufferPointer(buffer);
...
*
Unfortunately this is throwing the following exception:*
Exception in thread "main" java.lang.IllegalArgumentException: Non-direct
Buffer is not supported
at com.sun.jna.Native.getDirectBufferPointer(Native Method)
at jredeye.Main.main(Main.java:60)
If any further detail is required, please feel free to ask. Any help or
input on this would be greatly appreciated.
Regards
Drayton