Hi all
I would like to do the following using JNA:
typedef struct {
unsigned char *data[3];
} MyStruct;
unsigned char* lpImage;
lpImage = (unsigned char*) malloc ( sizeof(unsigned char*) *
iNumberOfChannel * iImageWidth, iImageHeight );
//fill the malloc'd memory
MyStruct myStuct;
myStuct.data[0] = lpImage;// my red channel
myStuct.data[1] = lpImage+1; // my green channel
myStuct.data[2] = lpImage+2; // my blue channel
I have tried a couple of things and now I believe this is the closest to
what I'm aiming to achieve:
I map the structure as follows:
public static class MyStruct extends Structure
public Pointer[] data= new Pointer[3];
}
I then do the malloc equivalent:
Memory memory = new Memory(iNumberOfChannel * iImageWidth, iImageHeight );
//fill the malloc'd memory
Then I set the structure pointers to point to the correct offsets in the
malloc'd memory:
MyStruct myStruct = new MyStruct();
myStruct.data[0] = memory.getPointer(0)
myStruct.data[1] = memory.getPointer(1)
myStruct.data[2] = memory.getPointer(2);
Unfortunately when I get the structure back from the function after
manipulation, it seems that the data has not been touched!
Please could someone confirm that I have done this correctly, if a nudge in
the right direction would be greatly appreciated!
Thanks!
Drayton