[英]JNA : Exception_Access_Violation
I use JNA to call this function in libpotrace.dll, this function is: 我使用JNA在libpotrace.dll中调用此函数,该函数是:
potrace_state_t *potrace_trace(const potrace_param_t *param,
const potrace_bitmap_t *bm);
The parameters in library are: 库中的参数为:
typedef unsigned long potrace_word;
struct potrace_bitmap_s {
int w, h; /* width and height, in pixels */
int dy; /* words per scanline (not bytes) */
potrace_word *map; /* raw data, dy*h words */
};
typedef struct potrace_bitmap_s potrace_bitmap_t;
struct potrace_param_s {
int turdsize; /* area of largest path to be ignored */
int turnpolicy; /* resolves ambiguous turns in path decomposition */
double alphamax; /* corner threshold */
int opticurve; /* use curve optimization? */
double opttolerance; /* curve optimization tolerance */
potrace_progress_t progress; /* progress callback function */
};
typedef struct potrace_param_s potrace_param_t;
in my java code I have: 在我的Java代码中,我有:
public class Potrace_bitmap_t extends Structure{
public int w=36;
public int h=2; /* width and height, in pixels */
public int dy=2; /* words per scanline (not bytes) */
public long [] map =new long[dy*h];
}
public class potrace_param_t extends Structure{
//public static class ByValue extends Nat implements Structure.ByValue { }
public int turdsize=0;
public int turnpolicy=0;
public double alphamax=0;
public int opticurve=0;
public double opttolerance=0;
}
potrace_param_t na=lib.potrace_param_default();/*This function returns a fresh set of tracing parameters, initialized to defaults.
Potrace_bitmap_t bm=new Potrace_bitmap_t();
bm.map[0]=1113215L;
bm.map[1]=4026531840L;
bm.map[2]=3276415L;
bm.map[3]=4026531840L;
Potrace_state_t pt=lib.potrace_trace(na, bm);
When I execute potrace_trace() this error occurs : 当我执行potrace_trace()时,会发生此错误:
An unexpected error has been detected by Java Runtime Environment:
EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x6504fbee, pid=2728, tid=2436
Java VM: Java HotSpot(TM) Client VM (1.6.0_03-b05 mixed mode, sharing)
Problematic frame:
C [libpotrace.dll+0xfbee]
An error report file with more information is saved as hs_err_pid2728.log
If you would like to submit a bug report, please visit:
http://java.sun.com/webapps/bugreport/crash.jsp
I do not understand why. 我不理解为什么。 thanks.
谢谢。
Your fourth field of Potrace_bitmap_t should be a pointer, not an array of 64-bit values. 您的Potrace_bitmap_t的第四个字段应该是一个指针,而不是64位值的数组。 You're missing the last field of potrace_param_t.
您缺少potrace_param_t的最后一个字段。
but in the doc of the library, I found this 但是在库的文档中,我发现了这个
w = 36;
h = 12;
dy = 2;
map[22] = 0xfff0fc02; map[23] = 0x00000000;
map[20] = 0x7ff1fe02; map[21] = 0x00000000;
map[18] = 0x3ff3ff07; map[19] = 0x00000000;
map[16] = 0x1ff7ff87; map[17] = 0x00000000;
map[14] = 0x0ff7cf8f; map[15] = 0x80000000;
map[12] = 0x07f7878f; map[13] = 0x80000000;
map[10] = 0x03f7879f; map[11] = 0xc0000000;
map[8] = 0x01f7cf9f; map[9] = 0xc0000000;
map[6] = 0x00f7ffbf; map[7] = 0xe0000000;
map[4] = 0x0073ff3f; map[5] = 0xe0000000;
map[2] = 0x0031fe7f; map[3] = 0xf0000000;
map[0] = 0x0010fc7f; map[1] = 0xf0000000;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.