4 messages in net.java.dev.jna.users[jna-users] Arrays offset
FromSent OnAttachments
Cyril DelmasMar 4, 2009 8:26 am 
Timothy WallMar 4, 2009 8:40 am 
Cyril DelmasMar 4, 2009 8:50 am 
Timothy WallMar 4, 2009 9:35 am 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:[jna-users] Arrays offsetActions...
From:Cyril Delmas (cyri@cgin.fr)
Date:Mar 4, 2009 8:26:52 am
List:net.java.dev.jna.users

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).

Can anyone help me ?

Regards.