On Mar 4, 2009, at 11:27 AM, Cyril Delmas wrote:
Hi list,
I want to transform this C code :
==========
LPBYTE lpImage = (LPBYTE) malloc ( sizeof(BYTE) * 3 * width *
height );
// initialize lpImage correctly
ImageTransfer IT;
IT.columnBytes = 3;
IT.rowBytes = 3 * width;
IT.height = height;
IT.width = width;
IT.data[0] = lpImage+2; // red channel
IT.data[1] = lpImage+1; // green channel
IT.data[2] = lpImage; // blue channel
// use IT
==========
into the equivalent in Java using JNA.
I don't know which type I must use for "data" in the ImageTransfer
structure :
typedef struct {
int width;
int height;
int rowBytes;
int columnBytes;
unsigned char *data[3];
} ImageTransfer;
and don't know how to initialize the structure in Java (using
Pointer, PointerByReference, ByteByReference or ByteBuffer ?). I
tried some combinations, without success (access violation).
It's an array of pointers, so use Pointer[] data = new Pointer[3];
what you assign to each pointer depends on your application.