svn-gvsig-desktop / trunk / libraries / libjni-mrsid / src / es / gva / cit / jmrsid / LTIImage.java @ 8460
History | View | Annotate | Download (9.36 KB)
1 | 3539 | nacho | /**********************************************************************
|
---|---|---|---|
2 | 662 | igbrotru | * $Id$
|
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 | 2214 | igbrotru | /* 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 | 662 | igbrotru | |
51 | package es.gva.cit.jmrsid; |
||
52 | |||
53 | |||
54 | /**
|
||
55 | 840 | igbrotru | * Clase base que representa a una im?gen.
|
56 | *
|
||
57 | 662 | igbrotru | * @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 | 720 | igbrotru | private int[] magsize=new int[2]; |
64 | 662 | igbrotru | private native long getMetadataNat(long cPtr); |
65 | 720 | igbrotru | 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 | 746 | igbrotru | private native int getGeoCoordNat(long cPtr, LTIGeoCoord geocoord); |
71 | 1124 | igbrotru | private native void FreeLTIImageNat(long cPtr); |
72 | 8460 | nacho | private native double getMinMagnificationNat(long cPtr); |
73 | private native double getMaxMagnificationNat(long cPtr); |
||
74 | 662 | igbrotru | |
75 | 746 | igbrotru | LTIGeoCoord geocoord=null;
|
76 | |||
77 | 1124 | igbrotru | public LTIImage(){}
|
78 | |||
79 | 662 | igbrotru | /**
|
80 | 1124 | igbrotru | * 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 | 1181 | igbrotru | //System.out.println("Finalizando LTIImage ..."+cPtr);
|
92 | 3539 | nacho | if(cPtr > 0){ |
93 | 1124 | igbrotru | FreeLTIImageNat(cPtr); |
94 | 3539 | nacho | cPtr = -1;
|
95 | } |
||
96 | 1124 | igbrotru | } |
97 | |||
98 | |||
99 | /**
|
||
100 | 840 | igbrotru | * Inicializa el objeto im?gen.
|
101 | 662 | igbrotru | * @throws MrSIDException, IOException
|
102 | */
|
||
103 | 1133 | igbrotru | public void initialize()throws MrSIDException{ |
104 | 662 | igbrotru | |
105 | 720 | igbrotru | String msg1="Error en initialize. El Open del MrSID no tuvo ?xito"; |
106 | 662 | igbrotru | String msg2="La llamada nativa a initialize ha devuelto un c?digo de error"; |
107 | 1133 | igbrotru | 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 | 662 | igbrotru | |
112 | } |
||
113 | |||
114 | |||
115 | /**
|
||
116 | 840 | igbrotru | * Obtiene los metadatos de la im?gen.
|
117 | 662 | igbrotru | * @throws MrSIDException, IOException
|
118 | 840 | igbrotru | * @return Objeto LTIMetadataDatabase que contiene los metadatos de la im?gen
|
119 | 662 | igbrotru | */
|
120 | public LTIMetadataDatabase getMetadata()throws MrSIDException{ |
||
121 | |||
122 | |||
123 | if(cPtr <= 0) |
||
124 | 720 | igbrotru | throw new MrSIDException("Error en getMetadataDatabase. El Open del MrSID no tuvo ?xito"); |
125 | 662 | igbrotru | |
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 | 840 | igbrotru | * Obtiene el ancho de la im?gen.
|
135 | 662 | igbrotru | *
|
136 | * @throws MrSIDException
|
||
137 | 840 | igbrotru | * @return entero con el ancho de la im?gen
|
138 | 662 | igbrotru | */
|
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 | 840 | igbrotru | * Obtiene el alto de la im?gen.
|
149 | 662 | igbrotru | *
|
150 | * @throws MrSIDException
|
||
151 | 840 | igbrotru | * @return alto de la im?gen
|
152 | 662 | igbrotru | */
|
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 | 840 | igbrotru | * Obtiene el n?mero de bandas.
|
163 | 662 | igbrotru | *
|
164 | * @throws MrSIDException
|
||
165 | 840 | igbrotru | * @return n?mero de bandas
|
166 | 662 | igbrotru | */
|
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 | 840 | igbrotru | * Obtiene el tipo de espacio de color usado en la im?gen.
|
177 | 662 | igbrotru | *
|
178 | * @throws MrSIDException
|
||
179 | 840 | igbrotru | * @return entero que representa una constante de la clase LTIColorSpace.
|
180 | 662 | igbrotru | */
|
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 | 840 | igbrotru | * Obtiene el tipo de datos usado en la im?gen.
|
191 | 662 | igbrotru | *
|
192 | * @throws MrSIDException
|
||
193 | 840 | igbrotru | * @return entero que representa una constante de la clase LTIDataType.
|
194 | 662 | igbrotru | */
|
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 | 720 | igbrotru | |
203 | |||
204 | /**
|
||
205 | 840 | igbrotru | * Obtiene el ancho y alto de la im?gen a partir de una valor de ampliaci?n dado.
|
206 | 720 | igbrotru | *
|
207 | * @throws MrSIDException
|
||
208 | 840 | igbrotru | * @return el ancho y alto de la im?gen
|
209 | 720 | igbrotru | */
|
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 | 840 | igbrotru | * Obtiene las propiedades del pixel de la im?gen.
|
226 | * @throws MrSIDException
|
||
227 | * @return un objeto de tipo LTIPixel conteniendo las propiedades
|
||
228 | 720 | igbrotru | */
|
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 | 746 | igbrotru | * Obtiene la informaci?n de georeferenciaci?n de la im?gen si la tiene.
|
245 | 840 | igbrotru | * @throws MrSIDException
|
246 | * @return un objeto de tipo LTIGeoCoord con la informaci?n de georeferenciaci?n
|
||
247 | 746 | igbrotru | */
|
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 | 840 | igbrotru | * 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 | 720 | igbrotru | */
|
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 | 840 | igbrotru | if(pixel.getPtr()<=0)return null; |
281 | else return pixel; |
||
282 | 720 | igbrotru | |
283 | } |
||
284 | |||
285 | /**
|
||
286 | 840 | igbrotru | * 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 | 720 | igbrotru | */
|
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 | 840 | igbrotru | if(pixel.getPtr()<=0)return null; |
299 | else return pixel; |
||
300 | 720 | igbrotru | |
301 | } |
||
302 | 8460 | nacho | |
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 | 720 | igbrotru | |
317 | 8460 | nacho | } |
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 | 720 | igbrotru | |
336 | 662 | igbrotru | } |