svn-gvsig-desktop / tags / gvsig_redes-0_1_0_Build_1231 / libraries / libjni-mrsid-macosx / src / ltiimage.cpp @ 43614
History | View | Annotate | Download (11.5 KB)
1 | 9099 | mija | /**********************************************************************
|
---|---|---|---|
2 | * $Id$
|
||
3 | *
|
||
4 | * Name: ltiimage.c
|
||
5 | * Project: JMRSID. Interfaz 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 | |||
52 | #include <jni.h> |
||
53 | #include <malloc.h> |
||
54 | #include "es_gva_cit_jmrsid_LTIImage.h" |
||
55 | #include "es_gva_cit_jmrsid_JNIBase.h" |
||
56 | |||
57 | #include "lt_types.h" |
||
58 | #include "lt_base.h" |
||
59 | #include "lt_fileSpec.h" |
||
60 | #include "lti_geoCoord.h" |
||
61 | #include "lti_pixel.h" |
||
62 | #include "lti_navigator.h" |
||
63 | #include "lti_sceneBuffer.h" |
||
64 | #include "lti_metadataDatabase.h" |
||
65 | #include "lti_metadataRecord.h" |
||
66 | #include "lti_utils.h" |
||
67 | #include "MrSIDImageReader.h" |
||
68 | #include "J2KImageReader.h" |
||
69 | #include "lti_imageReader.h" |
||
70 | #include "lti_sceneBuffer.h" |
||
71 | #include "lti_scene.h" |
||
72 | //#include "cpl_conv.h"
|
||
73 | //#include "TIFFImageWriter.h"
|
||
74 | |||
75 | LT_USE_NAMESPACE(LizardTech); |
||
76 | |||
77 | /******************************************************************************/
|
||
78 | // initialize
|
||
79 | /******************************************************************************/
|
||
80 | |||
81 | |||
82 | JNIEXPORT jint JNICALL Java_es_gva_cit_jmrsid_JNIBase_initializeNat |
||
83 | (JNIEnv *env, jobject obj, jlong cPtr){ |
||
84 | LTIImage *img = (LTIImage *) 0 ;
|
||
85 | int res = -1; |
||
86 | |||
87 | img = *(LTIImage **)&cPtr; |
||
88 | |||
89 | if(img!=NULL) |
||
90 | res = img->initialize(); |
||
91 | |||
92 | return res;
|
||
93 | |||
94 | } |
||
95 | |||
96 | /******************************************************************************/
|
||
97 | // getMetadata
|
||
98 | /******************************************************************************/
|
||
99 | |||
100 | JNIEXPORT jlong JNICALL Java_es_gva_cit_jmrsid_LTIImage_getMetadataNat |
||
101 | (JNIEnv *env, jobject obj, jlong cPtr){ |
||
102 | |||
103 | jlong jresult = 0 ;
|
||
104 | LTIImageReader *img = (LTIImageReader *) 0 ;
|
||
105 | LTIMetadataDatabase *metadata=NULL;
|
||
106 | |||
107 | img = *(LTIImageReader **)&cPtr; |
||
108 | if(img!=NULL){ |
||
109 | metadata = new LTIMetadataDatabase( img->getMetadata() );
|
||
110 | *(LTIMetadataDatabase **)&jresult = metadata; |
||
111 | } |
||
112 | |||
113 | return jresult;
|
||
114 | |||
115 | } |
||
116 | |||
117 | /******************************************************************************/
|
||
118 | // getWidth
|
||
119 | /******************************************************************************/
|
||
120 | |||
121 | |||
122 | JNIEXPORT jint JNICALL Java_es_gva_cit_jmrsid_JNIBase_getWidthNat |
||
123 | (JNIEnv *env, jobject obj, jlong cPtr){ |
||
124 | |||
125 | LTIImage *img = (LTIImage *) 0 ;
|
||
126 | int res = -1; |
||
127 | |||
128 | img = *(LTIImage **)&cPtr; |
||
129 | |||
130 | if(img!=NULL) |
||
131 | res = img->getWidth(); |
||
132 | |||
133 | return res;
|
||
134 | |||
135 | } |
||
136 | |||
137 | |||
138 | /******************************************************************************/
|
||
139 | // getHeight
|
||
140 | /******************************************************************************/
|
||
141 | |||
142 | |||
143 | JNIEXPORT jint JNICALL Java_es_gva_cit_jmrsid_JNIBase_getHeightNat |
||
144 | (JNIEnv *env, jobject obj, jlong cPtr){ |
||
145 | |||
146 | LTIImage *img = (LTIImage *) 0 ;
|
||
147 | int res = -1; |
||
148 | |||
149 | img = *(LTIImage **)&cPtr; |
||
150 | |||
151 | if(img!=NULL) |
||
152 | res = img->getHeight(); |
||
153 | |||
154 | return res;
|
||
155 | |||
156 | } |
||
157 | |||
158 | |||
159 | /******************************************************************************/
|
||
160 | // getDimsAtMagWidth
|
||
161 | /******************************************************************************/
|
||
162 | |||
163 | |||
164 | JNIEXPORT jint JNICALL Java_es_gva_cit_jmrsid_LTIImage_getDimsAtMagWidthNat |
||
165 | (JNIEnv *env, jobject obj, jlong cPtr, jdouble mag){ |
||
166 | |||
167 | LTIImage *img = (LTIImage *) 0 ;
|
||
168 | int res = -1; |
||
169 | int height;
|
||
170 | double mg=mag;
|
||
171 | |||
172 | img = *(LTIImage **)&cPtr; |
||
173 | |||
174 | if(img!=NULL) |
||
175 | img->getDimsAtMag((double)mg,(lt_uint32 &)res,(lt_uint32 &)height);
|
||
176 | |||
177 | return res;
|
||
178 | |||
179 | } |
||
180 | |||
181 | /******************************************************************************/
|
||
182 | // getDimsAtMagHeight
|
||
183 | /******************************************************************************/
|
||
184 | |||
185 | |||
186 | JNIEXPORT jint JNICALL Java_es_gva_cit_jmrsid_LTIImage_getDimsAtMagHeightNat |
||
187 | (JNIEnv *env, jobject obj, jlong cPtr, jdouble mag){ |
||
188 | |||
189 | LTIImage *img = (LTIImage *) 0 ;
|
||
190 | int res = -1; |
||
191 | int width;
|
||
192 | double mg=mag;
|
||
193 | |||
194 | img = *(LTIImage **)&cPtr; |
||
195 | |||
196 | if(img!=NULL) |
||
197 | img->getDimsAtMag((double)mg,(lt_uint32 &)width,(lt_uint32 &)res);
|
||
198 | |||
199 | return res;
|
||
200 | |||
201 | } |
||
202 | |||
203 | /******************************************************************************/
|
||
204 | // getStripHeight
|
||
205 | /******************************************************************************/
|
||
206 | |||
207 | |||
208 | JNIEXPORT jint JNICALL Java_es_gva_cit_jmrsid_JNIBase_getStripHeightNat |
||
209 | (JNIEnv *env, jobject obj, jlong cPtr){ |
||
210 | |||
211 | LTIImageReader *img = (LTIImageReader *) 0 ;
|
||
212 | int res = -1; |
||
213 | |||
214 | img = *(LTIImageReader **)&cPtr; |
||
215 | |||
216 | if(img!=NULL) |
||
217 | res = img->getStripHeight(); |
||
218 | |||
219 | return res;
|
||
220 | |||
221 | } |
||
222 | |||
223 | /******************************************************************************/
|
||
224 | // getNumBands
|
||
225 | /******************************************************************************/
|
||
226 | |||
227 | |||
228 | JNIEXPORT jint JNICALL Java_es_gva_cit_jmrsid_JNIBase_getNumBandsNat |
||
229 | (JNIEnv *env, jobject obj, jlong cPtr){ |
||
230 | |||
231 | LTIImage *img = (LTIImage *) 0 ;
|
||
232 | int res = -1; |
||
233 | |||
234 | img = *(LTIImage **)&cPtr; |
||
235 | |||
236 | if(img!=NULL) |
||
237 | res = img->getNumBands(); |
||
238 | |||
239 | return res;
|
||
240 | |||
241 | } |
||
242 | |||
243 | /******************************************************************************/
|
||
244 | // getColorSpace
|
||
245 | /******************************************************************************/
|
||
246 | |||
247 | |||
248 | JNIEXPORT jint JNICALL Java_es_gva_cit_jmrsid_JNIBase_getColorSpaceNat |
||
249 | (JNIEnv *env, jobject obj, jlong cPtr){ |
||
250 | |||
251 | LTIImage *img = (LTIImage *) 0 ;
|
||
252 | int res = -1; |
||
253 | |||
254 | img = *(LTIImage **)&cPtr; |
||
255 | |||
256 | if(img!=NULL) |
||
257 | res = img->getColorSpace(); |
||
258 | |||
259 | return res;
|
||
260 | |||
261 | } |
||
262 | |||
263 | /******************************************************************************/
|
||
264 | // getDataType
|
||
265 | /******************************************************************************/
|
||
266 | |||
267 | |||
268 | JNIEXPORT jint JNICALL Java_es_gva_cit_jmrsid_JNIBase_getDataTypeNat |
||
269 | (JNIEnv *env, jobject obj, jlong cPtr){ |
||
270 | |||
271 | LTIImage *img = (LTIImage *) 0 ;
|
||
272 | int res = -1; |
||
273 | |||
274 | img = *(LTIImage **)&cPtr; |
||
275 | |||
276 | if(img!=NULL) |
||
277 | res = img->getDataType(); |
||
278 | |||
279 | return res;
|
||
280 | |||
281 | } |
||
282 | |||
283 | /******************************************************************************/
|
||
284 | // getPixelProps
|
||
285 | /******************************************************************************/
|
||
286 | |||
287 | |||
288 | JNIEXPORT jlong JNICALL Java_es_gva_cit_jmrsid_LTIImage_getPixelPropsNat |
||
289 | (JNIEnv *env, jobject obj, jlong cPtr){ |
||
290 | |||
291 | jlong jresult = 0 ;
|
||
292 | /*LTIImage *img = (LTIImage *) 0 ;
|
||
293 | |||
294 | |||
295 | img = *(LTIImage **)&cPtr;
|
||
296 | if(img!=NULL){
|
||
297 | const LTIPixel& pixelprops = img->getPixelProps();
|
||
298 | *(LTIPixel **)&jresult = pixelprops;
|
||
299 | |||
300 | |||
301 | return (jlong)pixelprops;
|
||
302 | }*/
|
||
303 | return jresult;
|
||
304 | |||
305 | } |
||
306 | |||
307 | /******************************************************************************/
|
||
308 | // getGeoCoord
|
||
309 | /******************************************************************************/
|
||
310 | |||
311 | JNIEXPORT jint JNICALL Java_es_gva_cit_jmrsid_LTIImage_getGeoCoordNat |
||
312 | (JNIEnv *env, jobject obj, jlong cPtr, jobject geocoord){ |
||
313 | |||
314 | LTIImage *img = (LTIImage *) 0 ;
|
||
315 | jclass clase; |
||
316 | jfieldID id_campo; |
||
317 | |||
318 | img = *(LTIImage **)&cPtr; |
||
319 | if(img!=NULL){ |
||
320 | const LTIGeoCoord& geo = img->getGeoCoord();
|
||
321 | |||
322 | clase = env->GetObjectClass(geocoord); |
||
323 | id_campo = env->GetFieldID(clase, "xUL", "D"); |
||
324 | env->SetDoubleField(geocoord, id_campo, geo.getX()); |
||
325 | |||
326 | id_campo = env->GetFieldID(clase, "yUL", "D"); |
||
327 | env->SetDoubleField(geocoord, id_campo, geo.getY()); |
||
328 | |||
329 | id_campo = env->GetFieldID(clase, "xRes", "D"); |
||
330 | env->SetDoubleField(geocoord, id_campo, geo.getXRes()); |
||
331 | |||
332 | id_campo = env->GetFieldID(clase, "yRes", "D"); |
||
333 | env->SetDoubleField(geocoord, id_campo, geo.getYRes()); |
||
334 | |||
335 | id_campo = env->GetFieldID(clase, "xRot", "D"); |
||
336 | env->SetDoubleField(geocoord, id_campo, geo.getXRot()); |
||
337 | |||
338 | id_campo = env->GetFieldID(clase, "yRot", "D"); |
||
339 | env->SetDoubleField(geocoord, id_campo, geo.getYRot()); |
||
340 | return 1; |
||
341 | } |
||
342 | |||
343 | return -1; |
||
344 | } |
||
345 | |||
346 | /******************************************************************************/
|
||
347 | // getBackgroundPixel
|
||
348 | /******************************************************************************/
|
||
349 | |||
350 | |||
351 | JNIEXPORT jlong JNICALL Java_es_gva_cit_jmrsid_LTIImage_getBackgroundPixelNat |
||
352 | (JNIEnv *env, jobject obj, jlong cPtr){ |
||
353 | |||
354 | LTIImage *img = (LTIImage *) 0 ;
|
||
355 | jlong jresult = 0 ;
|
||
356 | |||
357 | img = *(LTIImage **)&cPtr; |
||
358 | |||
359 | if(img!=NULL){ |
||
360 | const LTIPixel *pixel=img->getBackgroundPixel();
|
||
361 | LTIPixel p=LTIPixel(*pixel); |
||
362 | *(LTIPixel **)&jresult = &p; |
||
363 | } |
||
364 | |||
365 | return jresult;
|
||
366 | |||
367 | } |
||
368 | |||
369 | |||
370 | /******************************************************************************/
|
||
371 | // getNoData
|
||
372 | /******************************************************************************/
|
||
373 | |||
374 | |||
375 | JNIEXPORT jlong JNICALL Java_es_gva_cit_jmrsid_LTIImage_getNoDataPixelNat |
||
376 | (JNIEnv *env, jobject obj, jlong cPtr){ |
||
377 | |||
378 | LTIImage *img = (LTIImage *) 0 ;
|
||
379 | jlong jresult = 0 ;
|
||
380 | |||
381 | img = *(LTIImage **)&cPtr; |
||
382 | |||
383 | if(img!=NULL){ |
||
384 | const LTIPixel *pixel=img->getNoDataPixel();
|
||
385 | LTIPixel p=LTIPixel(*pixel); |
||
386 | *(LTIPixel **)&jresult = &p; |
||
387 | } |
||
388 | |||
389 | return jresult;
|
||
390 | |||
391 | } |
||
392 | |||
393 | /******************************************************************************/
|
||
394 | // ~LTIImage
|
||
395 | /******************************************************************************/
|
||
396 | |||
397 | JNIEXPORT void JNICALL Java_es_gva_cit_jmrsid_LTIImage_FreeLTIImageNat
|
||
398 | (JNIEnv *env, jobject obj, jlong cPtr){ |
||
399 | |||
400 | LTIImage *img = (LTIImage *) 0 ;
|
||
401 | |||
402 | img = *(LTIImage **)&cPtr; |
||
403 | if(img!=NULL){ |
||
404 | delete img;
|
||
405 | } |
||
406 | |||
407 | } |
||
408 | |||
409 | /******************************************************************************/
|
||
410 | // getMinMagnification
|
||
411 | /******************************************************************************/
|
||
412 | |||
413 | |||
414 | JNIEXPORT jdouble JNICALL Java_es_gva_cit_jmrsid_LTIImage_getMinMagnificationNat |
||
415 | (JNIEnv *env, jobject obj, jlong cPtr){ |
||
416 | |||
417 | LTIImage *img = (LTIImage *) 0 ;
|
||
418 | double res = -1; |
||
419 | |||
420 | img = *(LTIImage **)&cPtr; |
||
421 | |||
422 | if(img!=NULL) |
||
423 | res = img->getMinMagnification(); |
||
424 | |||
425 | return (jdouble)res;
|
||
426 | |||
427 | } |
||
428 | |||
429 | /******************************************************************************/
|
||
430 | // getMaxMagnification
|
||
431 | /******************************************************************************/
|
||
432 | |||
433 | |||
434 | JNIEXPORT jdouble JNICALL Java_es_gva_cit_jmrsid_LTIImage_getMaxMagnificationNat |
||
435 | (JNIEnv *env, jobject obj, jlong cPtr){ |
||
436 | |||
437 | LTIImage *img = (LTIImage *) 0 ;
|
||
438 | double res = -1; |
||
439 | |||
440 | img = *(LTIImage **)&cPtr; |
||
441 | |||
442 | if(img!=NULL) |
||
443 | res = img->getMaxMagnification(); |
||
444 | |||
445 | return (jdouble)res;
|
||
446 | |||
447 | } |