Statistics
| Revision:

gvsig-raster / libjni-potrace / trunk / libjni-potrace / src / main / java / org / gvsig / jpotrace / Potrace.java @ 1780

History | View | Annotate | Download (2.39 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
package org.gvsig.jpotrace;
20
/**
21
 * La clase <code>Potrace</code> contiene los metodos que comunican la libreria
22
 * nativa con Java
23
 *  
24
 * @version 31/07/2008
25
 * @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es)
26
 */
27
public class Potrace extends JNIBase {
28
        private static native double[] vectorizeBufferRasterNat(int[] bufferIn, int width, int height, String[] params);
29

    
30
        /**
31
         * Vectoriza un buffer pasado por parametro y es devuelto en forma de array
32
         * de doubles. Hay que especificar el ancho y alto del buffer y el buffer ha
33
         * de ser pasado en el formato que soporta potrace, que es en forma de bits.
34
         * 
35
         * El parametro params es un array de Strings como se usaria en el tipico
36
         * main(char[]) para expresar los parametros de potrace, es una forma de poder
37
         * aprovechar todos los parametros del comando potrace desde Java. Algunos 
38
         * no funcionan, como especificar el fichero origen o destino
39
         * 
40
         * @param bufferIn
41
         * @param width
42
         * @param height
43
         * @param params
44
         * @return
45
         * @throws PotraceException
46
         */
47
        public static double[] vectorizeBufferRaster(int[] bufferIn, int width, int height, String[] params) throws PotraceException {
48
                if (bufferIn == null)
49
                        throw new PotraceException("El parametro Buffer no puede estar vacio");
50

    
51
                if (width <= 0)
52
                        throw new PotraceException("El ancho del buffer ha de ser mayor a 0");
53

    
54
                if (height <= 0)
55
                        throw new PotraceException("El alto del buffer ha de ser mayor a 0");
56

    
57
                return vectorizeBufferRasterNat(bufferIn, width, height, params);
58
        }
59
}