svn-gvsig-desktop / trunk / libraries / libjni-mrsid / src / es / gva / cit / jmrsid / LTIImage.java @ 3539
History | View | Annotate | Download (8.3 KB)
1 |
/**********************************************************************
|
---|---|
2 |
* $Id: LTIImage.java 3539 2006-01-09 12:23:20Z nacho $
|
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 |
import java.io.*; |
54 |
|
55 |
/**
|
56 |
* Clase base que representa a una im?gen.
|
57 |
*
|
58 |
* @author Nacho Brodin <brodin_ign@gva.es>.<BR> Equipo de desarrollo gvSIG.<BR> http://www.gvsig.gva.es
|
59 |
* @version 0.0
|
60 |
* @link http://www.gvsig.gva.es
|
61 |
*/
|
62 |
public class LTIImage extends JNIBase{ |
63 |
|
64 |
private int[] magsize=new int[2]; |
65 |
private native long getMetadataNat(long cPtr); |
66 |
private native int getDimsAtMagWidthNat(long cPtr, double mag); |
67 |
private native int getDimsAtMagHeightNat(long cPtr, double mag); |
68 |
private native long getPixelPropsNat(long cPtr); |
69 |
private native long getBackgroundPixelNat(long cPtr); |
70 |
private native long getNoDataPixelNat(long cPtr); |
71 |
private native int getGeoCoordNat(long cPtr, LTIGeoCoord geocoord); |
72 |
private native void FreeLTIImageNat(long cPtr); |
73 |
|
74 |
LTIGeoCoord geocoord=null;
|
75 |
|
76 |
public LTIImage(){}
|
77 |
|
78 |
/**
|
79 |
* Constructor
|
80 |
* @param cPtr direcci?n de memoria al objeto LTIImage de C.
|
81 |
*/
|
82 |
public LTIImage(long cPtr){ |
83 |
this.cPtr=cPtr;
|
84 |
} |
85 |
|
86 |
/**
|
87 |
* Destructor
|
88 |
*/
|
89 |
protected void finalize(){ |
90 |
//System.out.println("Finalizando LTIImage ..."+cPtr);
|
91 |
if(cPtr > 0){ |
92 |
FreeLTIImageNat(cPtr); |
93 |
cPtr = -1;
|
94 |
} |
95 |
} |
96 |
|
97 |
|
98 |
/**
|
99 |
* Inicializa el objeto im?gen.
|
100 |
* @throws MrSIDException, IOException
|
101 |
*/
|
102 |
public void initialize()throws MrSIDException{ |
103 |
|
104 |
String msg1="Error en initialize. El Open del MrSID no tuvo ?xito"; |
105 |
String msg2="La llamada nativa a initialize ha devuelto un c?digo de error"; |
106 |
int codigo = super.baseSimpleFunction(1,msg1,msg2); |
107 |
if( codigo>0) |
108 |
throw new MrSIDException("La llamada nativa a initialize ha devuelto el c?digo de error "+codigo); |
109 |
|
110 |
|
111 |
} |
112 |
|
113 |
|
114 |
/**
|
115 |
* Obtiene los metadatos de la im?gen.
|
116 |
* @throws MrSIDException, IOException
|
117 |
* @return Objeto LTIMetadataDatabase que contiene los metadatos de la im?gen
|
118 |
*/
|
119 |
public LTIMetadataDatabase getMetadata()throws MrSIDException{ |
120 |
|
121 |
|
122 |
if(cPtr <= 0) |
123 |
throw new MrSIDException("Error en getMetadataDatabase. El Open del MrSID no tuvo ?xito"); |
124 |
|
125 |
LTIMetadataDatabase metadata=new LTIMetadataDatabase(getMetadataNat(cPtr));
|
126 |
|
127 |
if(metadata==null) |
128 |
throw new MrSIDException("Objeto LTIMetadataDatabase nulo"); |
129 |
else return metadata; |
130 |
} |
131 |
|
132 |
/**
|
133 |
* Obtiene el ancho de la im?gen.
|
134 |
*
|
135 |
* @throws MrSIDException
|
136 |
* @return entero con el ancho de la im?gen
|
137 |
*/
|
138 |
public int getWidth()throws MrSIDException{ |
139 |
|
140 |
String msg1="Error en getNumLevels. No se ha obtenido un puntero valido a LTIImage"; |
141 |
String msg2="La llamada nativa a getNumLevels ha devuelto un c?digo de error"; |
142 |
return baseSimpleFunction(3,msg1,msg2); |
143 |
|
144 |
} |
145 |
|
146 |
/**
|
147 |
* Obtiene el alto de la im?gen.
|
148 |
*
|
149 |
* @throws MrSIDException
|
150 |
* @return alto de la im?gen
|
151 |
*/
|
152 |
public int getHeight()throws MrSIDException{ |
153 |
|
154 |
String msg1="Error en getNumLevels. No se ha obtenido un puntero valido a LTIImage"; |
155 |
String msg2="La llamada nativa a getNumLevels ha devuelto un c?digo de error"; |
156 |
return baseSimpleFunction(4,msg1,msg2); |
157 |
|
158 |
} |
159 |
|
160 |
/**
|
161 |
* Obtiene el n?mero de bandas.
|
162 |
*
|
163 |
* @throws MrSIDException
|
164 |
* @return n?mero de bandas
|
165 |
*/
|
166 |
public int getNumBands()throws MrSIDException{ |
167 |
|
168 |
String msg1="Error en getNumBands. No se ha obtenido un puntero valido a LTIImage"; |
169 |
String msg2="La llamada nativa a getNumBands ha devuelto un c?digo de error"; |
170 |
return baseSimpleFunction(6,msg1,msg2); |
171 |
|
172 |
} |
173 |
|
174 |
/**
|
175 |
* Obtiene el tipo de espacio de color usado en la im?gen.
|
176 |
*
|
177 |
* @throws MrSIDException
|
178 |
* @return entero que representa una constante de la clase LTIColorSpace.
|
179 |
*/
|
180 |
public int getColorSpace()throws MrSIDException{ |
181 |
|
182 |
String msg1="Error en getColorSpace. No se ha obtenido un puntero valido a LTIImage"; |
183 |
String msg2="La llamada nativa a getColorSpace ha devuelto un c?digo de error"; |
184 |
return baseSimpleFunction(7,msg1,msg2); |
185 |
|
186 |
} |
187 |
|
188 |
/**
|
189 |
* Obtiene el tipo de datos usado en la im?gen.
|
190 |
*
|
191 |
* @throws MrSIDException
|
192 |
* @return entero que representa una constante de la clase LTIDataType.
|
193 |
*/
|
194 |
public int getDataType()throws MrSIDException{ |
195 |
|
196 |
String msg1="Error en getDataType. No se ha obtenido un puntero valido a LTIImage"; |
197 |
String msg2="La llamada nativa a getDataType ha devuelto un c?digo de error"; |
198 |
return baseSimpleFunction(8,msg1,msg2); |
199 |
|
200 |
} |
201 |
|
202 |
|
203 |
/**
|
204 |
* Obtiene el ancho y alto de la im?gen a partir de una valor de ampliaci?n dado.
|
205 |
*
|
206 |
* @throws MrSIDException
|
207 |
* @return el ancho y alto de la im?gen
|
208 |
*/
|
209 |
public int[] getDimsAtMag(double mag)throws MrSIDException{ |
210 |
|
211 |
if(cPtr <= 0) |
212 |
throw new MrSIDException("Error en getDimsAtMag. El Open del MrSID no tuvo ?xito"); |
213 |
|
214 |
magsize[0]=getDimsAtMagWidthNat(cPtr,mag);
|
215 |
magsize[1]=getDimsAtMagHeightNat(cPtr,mag);
|
216 |
|
217 |
if(magsize[0]<0 || magsize[1]<0) |
218 |
throw new MrSIDException("Error en getDimsAtMag. El Open del MrSID no tuvo ?xito"); |
219 |
|
220 |
return magsize;
|
221 |
} |
222 |
|
223 |
/**
|
224 |
* Obtiene las propiedades del pixel de la im?gen.
|
225 |
* @throws MrSIDException
|
226 |
* @return un objeto de tipo LTIPixel conteniendo las propiedades
|
227 |
*/
|
228 |
public LTIPixel getPixelProps()throws MrSIDException{ |
229 |
|
230 |
if(cPtr <= 0) |
231 |
throw new MrSIDException("Error en getPixelProps. El Open del MrSID no tuvo ?xito"); |
232 |
|
233 |
LTIPixel props=new LTIPixel(getPixelPropsNat(cPtr));
|
234 |
|
235 |
if(props==null) |
236 |
throw new MrSIDException("Error en getPixelProps. No se ha podido obtener LTIPixel"); |
237 |
else
|
238 |
return props;
|
239 |
|
240 |
} |
241 |
|
242 |
/**
|
243 |
* Obtiene la informaci?n de georeferenciaci?n de la im?gen si la tiene.
|
244 |
* @throws MrSIDException
|
245 |
* @return un objeto de tipo LTIGeoCoord con la informaci?n de georeferenciaci?n
|
246 |
*/
|
247 |
public LTIGeoCoord getGeoCoord()throws MrSIDException{ |
248 |
|
249 |
int res=0; |
250 |
|
251 |
if(cPtr <= 0) |
252 |
throw new MrSIDException("Error en getGeoCoord. El Open del MrSID no tuvo ?xito"); |
253 |
|
254 |
if(geocoord==null){ |
255 |
geocoord= new LTIGeoCoord();
|
256 |
res = getGeoCoordNat(cPtr,geocoord); |
257 |
} |
258 |
|
259 |
if(res<0) |
260 |
throw new MrSIDException("Error en getGeoCoord. No se ha podido obtener un LTIGeoCoord valido"); |
261 |
else
|
262 |
return geocoord;
|
263 |
|
264 |
} |
265 |
|
266 |
/**
|
267 |
* Obtiene el valor del fondo del pixel. Si devuelve null es que no ha sido definido un valor para
|
268 |
* el fondo.
|
269 |
* @throws MrSIDException
|
270 |
* @return un objeto del tipo LTIPixel con los valores del fondo del pixel
|
271 |
*/
|
272 |
public LTIPixel getBackgroundPixel()throws MrSIDException{ |
273 |
|
274 |
if(cPtr <= 0) |
275 |
throw new MrSIDException("Error en getBackgroundPixel. El Open del MrSID no tuvo ?xito"); |
276 |
|
277 |
LTIPixel pixel=new LTIPixel(getBackgroundPixelNat(cPtr));
|
278 |
|
279 |
if(pixel.getPtr()<=0)return null; |
280 |
else return pixel; |
281 |
|
282 |
} |
283 |
|
284 |
/**
|
285 |
* Obtiene los valores de transparencia de un pixel. Si devuelve null es que la im?gen no tiene
|
286 |
* definido un valor de transparencia.
|
287 |
* @throws MrSIDException
|
288 |
* @return un objeto de tipo LTIPixel
|
289 |
*/
|
290 |
public LTIPixel getNoDataPixel()throws MrSIDException{ |
291 |
|
292 |
if(cPtr <= 0) |
293 |
throw new MrSIDException("Error en getNoData. El Open del MrSID no tuvo ?xito"); |
294 |
|
295 |
LTIPixel pixel=new LTIPixel(getNoDataPixelNat(cPtr));
|
296 |
|
297 |
if(pixel.getPtr()<=0)return null; |
298 |
else return pixel; |
299 |
|
300 |
} |
301 |
|
302 |
|
303 |
} |