5 messages in net.java.dev.jna.users[jna-users] Seemingly correct mapping...
FromSent OnAttachments
Andrew PullinJan 15, 2009 11:25 pm 
Jorge Nieto-MadridJan 16, 2009 4:25 am 
Timothy WallJan 16, 2009 6:34 am 
Jorge Nieto-MadridJan 16, 2009 8:13 am 
Timothy WallJan 16, 2009 8:37 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] Seemingly correct mapping results in heap space errorActions...
From:Andrew Pullin (pul@berkeley.edu)
Date:Jan 15, 2009 11:25:30 pm
List:net.java.dev.jna.users

Hey folks. I've managed to work through most of the problem's I'm hit with JNA so far, but I'm a little stuck on this one. I need to interface with a camera, which has a DLL interface. Here's the function I need to use:

//////// C code TRgbPix* SMXM7X_API CxBayerToRgb(void *BayerMatrix, int ScW, int ScH, int AlgId, TRgbPix *Frame); ////////

My java mapping: TRgbPix CxBayerToRgb(byte[] BayerMatrix, int ScW, int ScH, int AlgID, TRgbPix[] Frame);

And pertinent struct: ///// C code typedef struct _TRgbPix { BYTE b; BYTE g; BYTE r; } TRgbPix; ///////////

The Java version of that struct I am using is: public static class TRgbPix extends Structure { public static class ByValue extends TRgbPix implements Structure.ByValue { } public byte b; public byte g; public byte r; }

I'm invoking it as: byte[] buffer = new byte[100]; // Some stuff here to fill buffer TRgbPix[] frameOut = new TRgbPix[100]; SMXLibrary.INSTANCE.CxBayerToRgb(buffer, 10, 10, 2, frameOut);

The problem I get is a 10 second hang, followed by: Exception in thread "main" java.lang.OutOfMemoryError: Java heap space at java.lang.Class.getDeclaredFields0(Native Method) at java.lang.Class.privateGetDeclaredFields(Class.java:2291) etc

I'm fairly sure that it's not some silly indexing / row&column problem, as in using the function incorrectly. In the C code, the buffer is a BYTE array. Any ideas? I'm not sure what to do about the void * type being an argument, when it supposed to be a byte array.

Thanks, Andrew