Statistics
| Revision:

root / branches / v10 / libraries / libjni-gdal / src / es / gva / cit / jgdal / GdalColorTable.java @ 7847

History | View | Annotate | Download (1.48 KB)

1
package es.gva.cit.jgdal;
2

    
3
public class GdalColorTable extends JNIBase{
4
        
5
        private native int getColorEntryCountNat(long cPtr);
6
        private native short[] getColorEntryAsRGBNat(long cPtr, int pos);
7
        
8
        
9
        /**
10
         * Constructor de ColorTable pasandole como par?metro la referencia al objeto 
11
         * GdalColorTable en C
12
         * 
13
         * @param cPtr        direcci?n de memoria del objeto 
14
         */
15
        
16
        public GdalColorTable(long cPtr){
17
                this.cPtr=cPtr;
18
        }
19
        
20
        /**
21
         * Obtiene
22
         * @return
23
         * @throws GdalException
24
         */
25
        public int getColorEntryCount() throws GdalException{
26
                if(cPtr <= 0)
27
                        throw new GdalException("Error en getColorEntryCount(). La creaci?n de la tabla no tuvo exito");
28
                                 
29
                return getColorEntryCountNat(cPtr);
30
        }
31
        
32
        /**
33
         * Obtiene la entrada de la tabla de color de la posici?n pasada por par?metro
34
         * y la devuelve en forma de objeto GdalColorEntry.
35
         * @param pos Posici?n de la entrada de la tabla
36
         * @return Objeto GdalColorEntry correspondiente a pos
37
         * @throws GdalException
38
         */
39
        public GdalColorEntry getColorEntryAsRGB(int pos) throws GdalException{
40
                if(cPtr <= 0)
41
                        throw new GdalException("Error en getColorEntryAsRGB(). La creaci?n de la tabla no tuvo exito");
42
                GdalColorEntry entry = new GdalColorEntry();
43
                short[] values =  getColorEntryAsRGBNat(cPtr, pos);
44
                entry.c1 = values[0];
45
                entry.c2 = values[1];
46
                entry.c3 = values[2];
47
                entry.c4 = values[3];
48
                if(values == null)
49
                        throw new GdalException("Error en getColorEntryAsRGB(). Posici?n de la tabla de color inexistente.");
50
                return entry;
51
        }
52
}