4 messages in net.java.dev.jna.usersRe: [jna-users] Nested Structure alig...
FromSent OnAttachments
Francis FernandezApr 11, 2008 8:31 am 
Timothy WallApr 11, 2008 8:39 am 
Francis FernandezApr 11, 2008 8:47 am 
Timothy WallApr 11, 2008 9:22 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:Re: [jna-users] Nested Structure alignmentActions...
From:Francis Fernandez (fraf@infoinplace.net)
Date:Apr 11, 2008 8:47:20 am
List:net.java.dev.jna.users

I'm sorry. Here are the relevant structs from the API:

/// struct for image format typedef struct _VRmImageFormat { /// width in pixels VRmDWORD m_width; /// height in lines VRmDWORD m_height; /// color format enum VRmColorFormat m_color_format; /// bit combination of enum VRmImageModifier values int m_image_modifier; }VRmImageFormat;

/// struct for image container typedef struct _VRmImage { /// image format struct VRmImageFormat m_image_format; /// pointer to image buffer VRmBYTE* mp_buffer; /// pitch = number of bytes from (x,y) to (x,y+1) VRmDWORD m_pitch; /// timestamp of image in ms since last VRmUsbCamRestartTimer() double m_time_stamp; /// private = additional internal data void* mp_private; }VRmImage;

The function to grab an image from a running camera:

/// lock source image. /// use fp_frames_dropped check to see if frames have been dropped (optional, pass NULL otherwise), /// use VRmUsbCamConvertImage() to convert locked image to one of the formats in target format list VRM_API VRmRetVal VRmUsbCamLockNextImage(VRmUsbCamDevice f_device,VRmImage** fpp_image,VRmBOOL* fp_frames_dropped);

~Francis

On Fri, Apr 11, 2008 at 11:39 AM, Timothy Wall <twal@dev.java.net> wrote:

Helps to have the original C source. Verbal explanations are usually less accurate than compilable code.

On Apr 11, 2008, at 11:31 AM, Francis Fernandez wrote:

Thanks for the help with the Pointer issue. I'm now running across a problem with the raw images returned by the camera. The Structure for the image itself looks like this:

public class VRmImage extends Structure implements ByReference {

public VRmImageFormat m_image_format;

public Pointer mp_buffer;

public NativeLong m_pitch;

public double m_time_stamp;

public Pointer mp_private;

}

The VRmImageFormat Structure nested within it looks like this:

public class VRmImageFormat extends Structure {

public NativeLong m_width;

public NativeLong m_height;

//enum VRmColorFormat // { VRM_ARGB_4X8, VRM_BGR_3X8, VRM_RGB_565, VRM_YUYV_4X8, VRM_GRAY_8, VRM_BAYER_GBRG_8, // VRM_BAYER_BGGR_8, VRM_BAYER_RGGB_8, VRM_BAYER_GRBG_8, VRM_GRAY_10, VRM_BAYER_GBRG_10, // VRM_BAYER_BGGR_10, VRM_BAYER_RGGB_10, VRM_BAYER_GRBG_10 } public int m_color_format;

public int m_image_modifier;

}

When I attempt to grab a new image from the camera, it returns successful, and the object's toString() looks like this:

VRmImage(allocated@0x2fb2830 (40 bytes)) { VRmImageFormat m_image_format@0=VRmImageFormat(allocated@0x2fb2830 (40 bytes) (shared from allocated@0x2fb2830 (40 bytes))) { NativeLong m_width@0=48121264 NativeLong m_height@4=0 int m_color_format@8=0 int m_image_modifier@c=0 } Pointer mp_buffer@10=null NativeLong m_pitch@14=0 double m_time_stamp@18=0.0 Pointer mp_private@20=null }

The problem here is that the VRmImageFormat field is taking up the entirety of the Structure (at least, that's what it looks like to me). The format object is supposed to be inline in the image object, as I understand it, but it doesn't seem to be aligning properly. How can I best get this issue sorted out? Thank you.

~Francis