Statistics
| Revision:

svn-gvsig-desktop / tags / v1_0_1_RELEASE / libraries / libjni-mrsid / src / es / gva / cit / jmrsid / LTIImage.java @ 9531

History | View | Annotate | Download (9.36 KB)

1
/**********************************************************************
2
 * $Id: LTIImage.java 9531 2007-01-03 17:07:37Z  $
3
 *
4
 * Name:     LTIImage.java
5
 * Project:  JMRSID. Interface java to mrsid (Lizardtech).
6
 * Purpose:   
7
 * Author:   Nacho Brodin, brodin_ign@gva.es
8
 *
9
 **********************************************************************/
10
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
11
*
12
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
13
*
14
* This program is free software; you can redistribute it and/or
15
* modify it under the terms of the GNU General Public License
16
* as published by the Free Software Foundation; either version 2
17
* of the License, or (at your option) any later version.
18
*
19
* This program is distributed in the hope that it will be useful,
20
* but WITHOUT ANY WARRANTY; without even the implied warranty of
21
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22
* GNU General Public License for more details.
23
*
24
* You should have received a copy of the GNU General Public License
25
* along with this program; if not, write to the Free Software
26
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
27
*
28
* For more information, contact:
29
*
30
*  Generalitat Valenciana
31
*   Conselleria d'Infraestructures i Transport
32
*   Av. Blasco Ib??ez, 50
33
*   46010 VALENCIA
34
*   SPAIN
35
*
36
*      +34 963862235
37
*   gvsig@gva.es
38
*      www.gvsig.gva.es
39
*
40
*    or
41
*
42
*   IVER T.I. S.A
43
*   Salamanca 50
44
*   46005 Valencia
45
*   Spain
46
*
47
*   +34 963163400
48
*   dac@iver.es
49
*/
50

    
51
package es.gva.cit.jmrsid;
52

    
53

    
54
/**
55
 * Clase base que representa a una im?gen.
56
 * 
57
 * @author Nacho Brodin <brodin_ign@gva.es>.<BR> Equipo de desarrollo gvSIG.<BR> http://www.gvsig.gva.es
58
 * @version 0.0
59
 * @link http://www.gvsig.gva.es
60
 */
61
public class LTIImage extends JNIBase{
62
        
63
        private int[] magsize=new int[2];
64
        private native long getMetadataNat(long cPtr);
65
        private native int getDimsAtMagWidthNat(long cPtr, double mag);
66
        private native int getDimsAtMagHeightNat(long cPtr, double mag);
67
        private native long getPixelPropsNat(long cPtr);
68
        private native long getBackgroundPixelNat(long cPtr);
69
        private native long getNoDataPixelNat(long cPtr);
70
        private native int getGeoCoordNat(long cPtr, LTIGeoCoord geocoord);
71
        private native void FreeLTIImageNat(long cPtr);
72
        private native double getMinMagnificationNat(long cPtr);
73
        private native double getMaxMagnificationNat(long cPtr);
74
        
75
        LTIGeoCoord geocoord=null;
76
        
77
        public LTIImage(){}
78
        
79
        /**
80
         * Constructor
81
         * @param cPtr        direcci?n de memoria al objeto LTIImage de C. 
82
         */
83
        public LTIImage(long cPtr){
84
                this.cPtr=cPtr;
85
        }
86
        
87
        /**
88
         * Destructor 
89
         */
90
        protected void finalize(){
91
                //System.out.println("Finalizando LTIImage ..."+cPtr);
92
                if(cPtr > 0){
93
                        FreeLTIImageNat(cPtr);
94
                        cPtr = -1;
95
                }
96
        }
97
        
98
        
99
        /**
100
         * Inicializa el objeto im?gen.
101
         * @throws MrSIDException, IOException
102
         */
103
        public void initialize()throws MrSIDException{
104

    
105
                String msg1="Error en initialize. El Open del MrSID no tuvo ?xito";
106
                String msg2="La llamada nativa a initialize ha devuelto un c?digo de error";
107
                int codigo = super.baseSimpleFunction(1,msg1,msg2);
108
                if( codigo>0)
109
                        throw new MrSIDException("La llamada nativa a initialize ha devuelto el c?digo de error "+codigo);
110
                        
111
                
112
        }
113
        
114
        
115
        /**
116
         * Obtiene los metadatos de la im?gen.
117
         * @throws MrSIDException, IOException
118
         * @return Objeto LTIMetadataDatabase que contiene los metadatos de la im?gen
119
         */
120
        public LTIMetadataDatabase getMetadata()throws MrSIDException{
121

    
122
                                
123
                if(cPtr <= 0)
124
                         throw new MrSIDException("Error en getMetadataDatabase. El Open del MrSID no tuvo ?xito");
125

    
126
                LTIMetadataDatabase metadata=new LTIMetadataDatabase(getMetadataNat(cPtr));
127
                                
128
                if(metadata==null)
129
                         throw new MrSIDException("Objeto LTIMetadataDatabase nulo");
130
                 else return metadata;
131
        }
132
        
133
        /**
134
         * Obtiene el ancho de la im?gen.
135
         * 
136
         * @throws MrSIDException
137
         * @return entero con el ancho de la im?gen
138
         */
139
        public int getWidth()throws MrSIDException{
140
                
141
                String msg1="Error en getNumLevels. No se ha obtenido un puntero valido a LTIImage";
142
                String msg2="La llamada nativa a getNumLevels ha devuelto un c?digo de error";
143
                return baseSimpleFunction(3,msg1,msg2);
144
                
145
        }
146
        
147
        /**
148
         * Obtiene el alto de la im?gen.
149
         * 
150
         * @throws MrSIDException
151
         * @return alto de la im?gen
152
         */
153
        public int getHeight()throws MrSIDException{
154
                
155
                String msg1="Error en getNumLevels. No se ha obtenido un puntero valido a LTIImage";
156
                String msg2="La llamada nativa a getNumLevels ha devuelto un c?digo de error";
157
                return baseSimpleFunction(4,msg1,msg2);
158
                
159
        }
160
        
161
        /**
162
         * Obtiene el n?mero de bandas.
163
         * 
164
         * @throws MrSIDException
165
         * @return n?mero de bandas
166
         */
167
        public int getNumBands()throws MrSIDException{
168
                
169
                String msg1="Error en getNumBands. No se ha obtenido un puntero valido a LTIImage";
170
                String msg2="La llamada nativa a getNumBands ha devuelto un c?digo de error";
171
                return baseSimpleFunction(6,msg1,msg2);
172
                
173
        }
174
        
175
        /**
176
         * Obtiene el tipo de espacio de color usado en la im?gen.
177
         * 
178
         * @throws MrSIDException
179
         * @return entero que representa una constante de la clase LTIColorSpace. 
180
         */
181
        public int getColorSpace()throws MrSIDException{
182
                
183
                String msg1="Error en getColorSpace. No se ha obtenido un puntero valido a LTIImage";
184
                String msg2="La llamada nativa a getColorSpace ha devuelto un c?digo de error";
185
                return baseSimpleFunction(7,msg1,msg2);
186
                
187
        }
188
        
189
        /**
190
         * Obtiene el tipo de datos usado en la im?gen.
191
         * 
192
         * @throws MrSIDException
193
         * @return entero que representa una constante de la clase LTIDataType. 
194
         */
195
        public int getDataType()throws MrSIDException{
196
                
197
                String msg1="Error en getDataType. No se ha obtenido un puntero valido a LTIImage";
198
                String msg2="La llamada nativa a getDataType ha devuelto un c?digo de error";
199
                return baseSimpleFunction(8,msg1,msg2);
200
                
201
        }
202

    
203
        
204
        /**
205
         * Obtiene el ancho y alto de la im?gen a partir de una valor de ampliaci?n dado.
206
         * 
207
         * @throws MrSIDException
208
         * @return el ancho y alto de la im?gen
209
         */
210
        public int[] getDimsAtMag(double mag)throws MrSIDException{
211
                
212
                if(cPtr <= 0)
213
                         throw new MrSIDException("Error en getDimsAtMag. El Open del MrSID no tuvo ?xito");
214

    
215
                magsize[0]=getDimsAtMagWidthNat(cPtr,mag);
216
                magsize[1]=getDimsAtMagHeightNat(cPtr,mag);
217
                
218
                if(magsize[0]<0 || magsize[1]<0)
219
                        throw new MrSIDException("Error en getDimsAtMag. El Open del MrSID no tuvo ?xito");
220
                                
221
                return magsize;
222
        }
223
        
224
        /**
225
         * Obtiene las propiedades del pixel de la im?gen.
226
         * @throws MrSIDException 
227
         * @return un objeto de tipo LTIPixel conteniendo las propiedades
228
         */
229
         public LTIPixel getPixelProps()throws MrSIDException{
230
                 
231
                 if(cPtr <= 0)
232
                         throw new MrSIDException("Error en getPixelProps. El Open del MrSID no tuvo ?xito");
233

    
234
                 LTIPixel props=new LTIPixel(getPixelPropsNat(cPtr));
235
                 
236
                 if(props==null)
237
                         throw new MrSIDException("Error en getPixelProps. No se ha podido obtener LTIPixel");
238
                 else
239
                         return props;
240
                 
241
         }
242
         
243
         /**
244
          * Obtiene la informaci?n de georeferenciaci?n de la im?gen si la tiene. 
245
          * @throws MrSIDException
246
          * @return un objeto de tipo LTIGeoCoord con la informaci?n de georeferenciaci?n 
247
          */
248
         public LTIGeoCoord getGeoCoord()throws MrSIDException{
249
                 
250
                 int res=0;
251
                 
252
                 if(cPtr <= 0)
253
                         throw new MrSIDException("Error en getGeoCoord. El Open del MrSID no tuvo ?xito");
254
                 
255
                 if(geocoord==null){
256
                         geocoord= new LTIGeoCoord();
257
                         res = getGeoCoordNat(cPtr,geocoord);
258
                 }
259
                 
260
                 if(res<0)
261
                         throw new MrSIDException("Error en getGeoCoord. No se ha podido obtener un LTIGeoCoord valido");
262
                 else 
263
                         return geocoord;
264
                 
265
         }
266
         
267
         /**
268
          * Obtiene el valor del fondo del pixel. Si devuelve null es que no ha sido definido un valor para 
269
          * el fondo.
270
          * @throws MrSIDException
271
          * @return un objeto del tipo LTIPixel con los valores del fondo del pixel
272
          */
273
         public LTIPixel getBackgroundPixel()throws MrSIDException{
274
                 
275
                 if(cPtr <= 0)
276
                         throw new MrSIDException("Error en getBackgroundPixel. El Open del MrSID no tuvo ?xito");
277
                 
278
                 LTIPixel pixel=new LTIPixel(getBackgroundPixelNat(cPtr));
279
                 
280
                 if(pixel.getPtr()<=0)return null;
281
                 else return pixel;
282
                 
283
         }
284
         
285
         /**
286
          * Obtiene los valores de transparencia de un pixel. Si devuelve null es que la im?gen no tiene
287
          * definido un valor de transparencia. 
288
          * @throws MrSIDException
289
          * @return un objeto de tipo LTIPixel
290
          */
291
         public LTIPixel getNoDataPixel()throws MrSIDException{
292
                 
293
                 if(cPtr <= 0)
294
                         throw new MrSIDException("Error en getNoData. El Open del MrSID no tuvo ?xito");
295
                 
296
                 LTIPixel pixel=new LTIPixel(getNoDataPixelNat(cPtr));
297
                 
298
                 if(pixel.getPtr()<=0)return null;
299
                 else return pixel;
300

    
301
         }
302
         
303
         /**
304
          * This function returns the minimum magnification of the image. 
305
          * Images that do not support "zooming out" will return 1.0; images that contain "overviews"
306
          * 
307
          * @throws MrSIDException
308
          * @return the minimum magnification
309
          */
310
          public double getMinMagnification()throws MrSIDException{
311
                        
312
                if(cPtr <= 0)
313
                         throw new MrSIDException("Error en getMinMagnification(). El Open del MrSID no tuvo ?xito");
314
                        
315
                return this.getMinMagnificationNat(cPtr);
316
        
317
          }
318
          
319
          /**
320
           * This function returns the minimum magnification of the image. 
321
           * Images that do not support "zooming out" will return 1.0; images that contain "overviews"
322
           * 
323
           * @throws MrSIDException
324
           * @return the minimum magnification
325
           */
326
           public double getMaxMagnification()throws MrSIDException{
327
                                
328
                if(cPtr <= 0)
329
                         throw new MrSIDException("Error en getMaxMagnification(). El Open del MrSID no tuvo ?xito");
330
                                
331
                return this.getMaxMagnificationNat(cPtr);
332
                
333
           }
334
        
335

    
336
}