Revision 23060

View differences:

trunk/libraries/libjni-potrace/src/main/java/org/gvsig/jpotrace/Potrace.java
24 24
 */
25 25
public class Potrace extends JNIBase {
26 26
	private static native void vectorizeRasterNat(String filein, String fileout);
27
	private static native void vectorizeBufferRasterNat(int[] filein, int width, int height, String fileout);
27
	private static native double[] vectorizeBufferRasterNat(int[] filein, int width, int height);
28 28

  
29 29
	/**
30 30
	 * Vectoriza un fichero pasado por parametro y lo guarda en fileOut
......
59 59
	 * @param fileOut
60 60
	 * @throws PotraceException
61 61
	 */
62
	public static void vectorizeBufferRaster(int[] bufferIn, int width, int height, String fileOut) throws PotraceException {
62
	public static double[] vectorizeBufferRaster(int[] bufferIn, int width, int height) throws PotraceException {
63 63
		if (bufferIn == null)
64 64
			throw new PotraceException("El nombre del driver es null");
65 65

  
66
		if (fileOut == null)
67
			throw new PotraceException("El nombre del driver es null");
68
		
69
		vectorizeBufferRasterNat(bufferIn, width, height, fileOut);
66
		return vectorizeBufferRasterNat(bufferIn, width, height);
70 67
	}
71 68
}
trunk/libraries/libjni-potrace/src/main/native/jpotrace/potrace.c
45 45
/**
46 46
 * Parte de jni para vectorizar un buffer
47 47
 */
48
JNIEXPORT void JNICALL Java_org_gvsig_jpotrace_Potrace_vectorizeBufferRasterNat(JNIEnv *env, jclass clase, jintArray bufferIn, jint width, jint height, jstring fileout) {
48
JNIEXPORT jdoubleArray JNICALL Java_org_gvsig_jpotrace_Potrace_vectorizeBufferRasterNat(JNIEnv *env, jclass clase, jintArray bufferIn, jint width, jint height) {
49 49
	int i;
50 50
	jint *cbufferIn;
51
	const char *outfile;
51
	double *values;
52
	jsize size;
53
	jdoubleArray jvalues;
52 54

  
53 55
	cbufferIn = (*env)->GetIntArrayElements(env, bufferIn, NULL);
54 56

  
55
	outfile = (*env)->GetStringUTFChars(env, fileout, 0);
57
	values = vectorizarBuffer((long *) cbufferIn, width, height);
58
	size = (jsize) values[0];
59
	jvalues = (*env)->NewDoubleArray(env, size);
60
	(*env)->SetDoubleArrayRegion(env, jvalues, 0, size, values);
56 61

  
57
	vectorizarBuffer((long *) cbufferIn, width, height, outfile);
62
	(*env)->ReleaseIntArrayElements(env, bufferIn, cbufferIn, 0);
58 63

  
59
	(*env)->ReleaseStringUTFChars(env, fileout, outfile);
60
	(*env)->ReleaseIntArrayElements(env, bufferIn, cbufferIn, 0);
64
	return jvalues;
61 65
}

Also available in: Unified diff