Statistics
| Revision:

svn-gvsig-desktop / trunk / libraries / libjni-potrace / src / main / native / jpotrace / potrace.c @ 23060

History | View | Annotate | Download (2.25 KB)

1
/* gvSIG. Sistema de Informaci�n Geogr�fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 */
19
#include <jni.h>
20
#include <stdio.h>
21
#include <string.h>
22
#include "potrace_raster.h"
23

    
24
/**
25
 * Parte de jni para vectorizar un fichero de disco
26
 */
27
JNIEXPORT void JNICALL Java_org_gvsig_jpotrace_Potrace_vectorizeRasterNat(JNIEnv *env, jclass clase, jstring filein, jstring fileout) {
28
        const char *infile;
29
        const char *outfile;
30

    
31
        printf("potrace.c: Java_org_gvsig_jpotrace_Potrace_vectorizeRasterNat\n");
32

    
33
        infile = (*env)->GetStringUTFChars(env, filein, 0);
34
        outfile = (*env)->GetStringUTFChars(env, fileout, 0);
35

    
36
        printf("potrace.c: Filein: %s\n", infile);
37
        printf("potrace.c: Fileout: %s\n", outfile);
38

    
39
        vectorizar(infile, outfile);
40

    
41
        (*env)->ReleaseStringUTFChars(env, filein, infile);
42
        (*env)->ReleaseStringUTFChars(env, fileout, outfile);
43
}
44

    
45
/**
46
 * Parte de jni para vectorizar un buffer
47
 */
48
JNIEXPORT jdoubleArray JNICALL Java_org_gvsig_jpotrace_Potrace_vectorizeBufferRasterNat(JNIEnv *env, jclass clase, jintArray bufferIn, jint width, jint height) {
49
        int i;
50
        jint *cbufferIn;
51
        double *values;
52
        jsize size;
53
        jdoubleArray jvalues;
54

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

    
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);
61

    
62
        (*env)->ReleaseIntArrayElements(env, bufferIn, cbufferIn, 0);
63

    
64
        return jvalues;
65
}