svn-gvsig-desktop / trunk / libraries / libjni-mrsid / src / ltiimage.cpp @ 3539
History | View | Annotate | Download (10.5 KB)
1 | 662 | igbrotru | /**********************************************************************
|
---|---|---|---|
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 | 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 | |||
52 | #include <jni.h> |
||
53 | 720 | igbrotru | #include <malloc.h> |
54 | 662 | igbrotru | #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 | |||
85 | LTIImage *img = (LTIImage *) 0 ;
|
||
86 | int res = -1; |
||
87 | |||
88 | img = *(LTIImage **)&cPtr; |
||
89 | |||
90 | if(img!=NULL) |
||
91 | res = img->initialize(); |
||
92 | |||
93 | return res;
|
||
94 | |||
95 | } |
||
96 | |||
97 | /******************************************************************************/
|
||
98 | // getMetadata
|
||
99 | /******************************************************************************/
|
||
100 | |||
101 | JNIEXPORT jlong JNICALL Java_es_gva_cit_jmrsid_LTIImage_getMetadataNat |
||
102 | (JNIEnv *env, jobject obj, jlong cPtr){ |
||
103 | |||
104 | jlong jresult = 0 ;
|
||
105 | LTIImageReader *img = (LTIImageReader *) 0 ;
|
||
106 | LTIMetadataDatabase *metadata=NULL;
|
||
107 | |||
108 | img = *(LTIImageReader **)&cPtr; |
||
109 | if(img!=NULL){ |
||
110 | metadata = new LTIMetadataDatabase( img->getMetadata() );
|
||
111 | *(LTIMetadataDatabase **)&jresult = metadata; |
||
112 | } |
||
113 | |||
114 | return jresult;
|
||
115 | |||
116 | } |
||
117 | |||
118 | /******************************************************************************/
|
||
119 | // getWidth
|
||
120 | /******************************************************************************/
|
||
121 | |||
122 | |||
123 | JNIEXPORT jint JNICALL Java_es_gva_cit_jmrsid_JNIBase_getWidthNat |
||
124 | (JNIEnv *env, jobject obj, jlong cPtr){ |
||
125 | |||
126 | LTIImage *img = (LTIImage *) 0 ;
|
||
127 | int res = -1; |
||
128 | |||
129 | img = *(LTIImage **)&cPtr; |
||
130 | |||
131 | if(img!=NULL) |
||
132 | res = img->getWidth(); |
||
133 | |||
134 | return res;
|
||
135 | |||
136 | } |
||
137 | |||
138 | |||
139 | /******************************************************************************/
|
||
140 | // getHeight
|
||
141 | /******************************************************************************/
|
||
142 | |||
143 | |||
144 | JNIEXPORT jint JNICALL Java_es_gva_cit_jmrsid_JNIBase_getHeightNat |
||
145 | (JNIEnv *env, jobject obj, jlong cPtr){ |
||
146 | |||
147 | LTIImage *img = (LTIImage *) 0 ;
|
||
148 | int res = -1; |
||
149 | |||
150 | img = *(LTIImage **)&cPtr; |
||
151 | |||
152 | if(img!=NULL) |
||
153 | res = img->getHeight(); |
||
154 | |||
155 | return res;
|
||
156 | |||
157 | } |
||
158 | |||
159 | 720 | igbrotru | |
160 | 662 | igbrotru | /******************************************************************************/
|
161 | 720 | igbrotru | // getDimsAtMagWidth
|
162 | /******************************************************************************/
|
||
163 | |||
164 | |||
165 | JNIEXPORT jint JNICALL Java_es_gva_cit_jmrsid_LTIImage_getDimsAtMagWidthNat |
||
166 | (JNIEnv *env, jobject obj, jlong cPtr, jdouble mag){ |
||
167 | |||
168 | LTIImage *img = (LTIImage *) 0 ;
|
||
169 | int res = -1; |
||
170 | int height;
|
||
171 | double mg=mag;
|
||
172 | |||
173 | img = *(LTIImage **)&cPtr; |
||
174 | |||
175 | if(img!=NULL) |
||
176 | img->getDimsAtMag((double)mg,(lt_uint32 &)res,(lt_uint32 &)height);
|
||
177 | |||
178 | return res;
|
||
179 | |||
180 | } |
||
181 | |||
182 | /******************************************************************************/
|
||
183 | // getDimsAtMagHeight
|
||
184 | /******************************************************************************/
|
||
185 | |||
186 | |||
187 | JNIEXPORT jint JNICALL Java_es_gva_cit_jmrsid_LTIImage_getDimsAtMagHeightNat |
||
188 | (JNIEnv *env, jobject obj, jlong cPtr, jdouble mag){ |
||
189 | |||
190 | LTIImage *img = (LTIImage *) 0 ;
|
||
191 | int res = -1; |
||
192 | int width;
|
||
193 | double mg=mag;
|
||
194 | |||
195 | img = *(LTIImage **)&cPtr; |
||
196 | |||
197 | if(img!=NULL) |
||
198 | img->getDimsAtMag((double)mg,(lt_uint32 &)width,(lt_uint32 &)res);
|
||
199 | |||
200 | return res;
|
||
201 | |||
202 | } |
||
203 | |||
204 | /******************************************************************************/
|
||
205 | 662 | igbrotru | // getStripHeight
|
206 | /******************************************************************************/
|
||
207 | |||
208 | |||
209 | JNIEXPORT jint JNICALL Java_es_gva_cit_jmrsid_JNIBase_getStripHeightNat |
||
210 | (JNIEnv *env, jobject obj, jlong cPtr){ |
||
211 | |||
212 | LTIImageReader *img = (LTIImageReader *) 0 ;
|
||
213 | int res = -1; |
||
214 | |||
215 | img = *(LTIImageReader **)&cPtr; |
||
216 | |||
217 | if(img!=NULL) |
||
218 | res = img->getStripHeight(); |
||
219 | |||
220 | return res;
|
||
221 | |||
222 | } |
||
223 | |||
224 | /******************************************************************************/
|
||
225 | // getNumBands
|
||
226 | /******************************************************************************/
|
||
227 | |||
228 | |||
229 | JNIEXPORT jint JNICALL Java_es_gva_cit_jmrsid_JNIBase_getNumBandsNat |
||
230 | (JNIEnv *env, jobject obj, jlong cPtr){ |
||
231 | |||
232 | LTIImage *img = (LTIImage *) 0 ;
|
||
233 | int res = -1; |
||
234 | |||
235 | img = *(LTIImage **)&cPtr; |
||
236 | |||
237 | if(img!=NULL) |
||
238 | res = img->getNumBands(); |
||
239 | |||
240 | return res;
|
||
241 | |||
242 | } |
||
243 | |||
244 | /******************************************************************************/
|
||
245 | // getColorSpace
|
||
246 | /******************************************************************************/
|
||
247 | |||
248 | |||
249 | JNIEXPORT jint JNICALL Java_es_gva_cit_jmrsid_JNIBase_getColorSpaceNat |
||
250 | (JNIEnv *env, jobject obj, jlong cPtr){ |
||
251 | |||
252 | LTIImage *img = (LTIImage *) 0 ;
|
||
253 | int res = -1; |
||
254 | |||
255 | img = *(LTIImage **)&cPtr; |
||
256 | |||
257 | if(img!=NULL) |
||
258 | res = img->getColorSpace(); |
||
259 | |||
260 | return res;
|
||
261 | |||
262 | } |
||
263 | |||
264 | /******************************************************************************/
|
||
265 | // getDataType
|
||
266 | /******************************************************************************/
|
||
267 | |||
268 | |||
269 | JNIEXPORT jint JNICALL Java_es_gva_cit_jmrsid_JNIBase_getDataTypeNat |
||
270 | (JNIEnv *env, jobject obj, jlong cPtr){ |
||
271 | |||
272 | LTIImage *img = (LTIImage *) 0 ;
|
||
273 | int res = -1; |
||
274 | |||
275 | img = *(LTIImage **)&cPtr; |
||
276 | |||
277 | if(img!=NULL) |
||
278 | res = img->getDataType(); |
||
279 | |||
280 | return res;
|
||
281 | |||
282 | } |
||
283 | |||
284 | 720 | igbrotru | /******************************************************************************/
|
285 | // getPixelProps
|
||
286 | /******************************************************************************/
|
||
287 | |||
288 | |||
289 | JNIEXPORT jlong JNICALL Java_es_gva_cit_jmrsid_LTIImage_getPixelPropsNat |
||
290 | (JNIEnv *env, jobject obj, jlong cPtr){ |
||
291 | |||
292 | jlong jresult = 0 ;
|
||
293 | /*LTIImage *img = (LTIImage *) 0 ;
|
||
294 | |||
295 | 662 | igbrotru | |
296 | 720 | igbrotru | img = *(LTIImage **)&cPtr;
|
297 | if(img!=NULL){
|
||
298 | const LTIPixel& pixelprops = img->getPixelProps();
|
||
299 | *(LTIPixel **)&jresult = pixelprops;
|
||
300 | |||
301 | 662 | igbrotru | |
302 | 720 | igbrotru | return (jlong)pixelprops;
|
303 | }*/
|
||
304 | return jresult;
|
||
305 | |||
306 | } |
||
307 | |||
308 | /******************************************************************************/
|
||
309 | 746 | igbrotru | // getGeoCoord
|
310 | /******************************************************************************/
|
||
311 | |||
312 | JNIEXPORT jint JNICALL Java_es_gva_cit_jmrsid_LTIImage_getGeoCoordNat |
||
313 | (JNIEnv *env, jobject obj, jlong cPtr, jobject geocoord){ |
||
314 | |||
315 | LTIImage *img = (LTIImage *) 0 ;
|
||
316 | jclass clase; |
||
317 | jfieldID id_campo; |
||
318 | |||
319 | img = *(LTIImage **)&cPtr; |
||
320 | if(img!=NULL){ |
||
321 | const LTIGeoCoord& geo = img->getGeoCoord();
|
||
322 | |||
323 | clase = env->GetObjectClass(geocoord); |
||
324 | id_campo = env->GetFieldID(clase, "xUL", "D"); |
||
325 | env->SetDoubleField(geocoord, id_campo, geo.getX()); |
||
326 | |||
327 | id_campo = env->GetFieldID(clase, "yUL", "D"); |
||
328 | env->SetDoubleField(geocoord, id_campo, geo.getY()); |
||
329 | |||
330 | id_campo = env->GetFieldID(clase, "xRes", "D"); |
||
331 | env->SetDoubleField(geocoord, id_campo, geo.getXRes()); |
||
332 | |||
333 | id_campo = env->GetFieldID(clase, "yRes", "D"); |
||
334 | env->SetDoubleField(geocoord, id_campo, geo.getYRes()); |
||
335 | |||
336 | id_campo = env->GetFieldID(clase, "xRot", "D"); |
||
337 | env->SetDoubleField(geocoord, id_campo, geo.getXRot()); |
||
338 | |||
339 | id_campo = env->GetFieldID(clase, "yRot", "D"); |
||
340 | env->SetDoubleField(geocoord, id_campo, geo.getYRot()); |
||
341 | return 1; |
||
342 | } |
||
343 | |||
344 | return -1; |
||
345 | } |
||
346 | |||
347 | /******************************************************************************/
|
||
348 | 720 | igbrotru | // getBackgroundPixel
|
349 | /******************************************************************************/
|
||
350 | |||
351 | |||
352 | JNIEXPORT jlong JNICALL Java_es_gva_cit_jmrsid_LTIImage_getBackgroundPixelNat |
||
353 | (JNIEnv *env, jobject obj, jlong cPtr){ |
||
354 | |||
355 | LTIImage *img = (LTIImage *) 0 ;
|
||
356 | jlong jresult = 0 ;
|
||
357 | |||
358 | img = *(LTIImage **)&cPtr; |
||
359 | |||
360 | if(img!=NULL){ |
||
361 | const LTIPixel *pixel=img->getBackgroundPixel();
|
||
362 | LTIPixel p=LTIPixel(*pixel); |
||
363 | *(LTIPixel **)&jresult = &p; |
||
364 | } |
||
365 | |||
366 | return jresult;
|
||
367 | |||
368 | } |
||
369 | |||
370 | |||
371 | /******************************************************************************/
|
||
372 | // getNoData
|
||
373 | /******************************************************************************/
|
||
374 | |||
375 | |||
376 | JNIEXPORT jlong JNICALL Java_es_gva_cit_jmrsid_LTIImage_getNoDataPixelNat |
||
377 | (JNIEnv *env, jobject obj, jlong cPtr){ |
||
378 | |||
379 | LTIImage *img = (LTIImage *) 0 ;
|
||
380 | jlong jresult = 0 ;
|
||
381 | |||
382 | img = *(LTIImage **)&cPtr; |
||
383 | |||
384 | if(img!=NULL){ |
||
385 | const LTIPixel *pixel=img->getNoDataPixel();
|
||
386 | LTIPixel p=LTIPixel(*pixel); |
||
387 | *(LTIPixel **)&jresult = &p; |
||
388 | } |
||
389 | |||
390 | return jresult;
|
||
391 | |||
392 | } |
||
393 | |||
394 | 1124 | igbrotru | /******************************************************************************/
|
395 | // ~LTIImage
|
||
396 | /******************************************************************************/
|
||
397 | |||
398 | JNIEXPORT void JNICALL Java_es_gva_cit_jmrsid_LTIImage_FreeLTIImageNat
|
||
399 | (JNIEnv *env, jobject obj, jlong cPtr){ |
||
400 | |||
401 | LTIImage *img = (LTIImage *) 0 ;
|
||
402 | |||
403 | img = *(LTIImage **)&cPtr; |
||
404 | if(img!=NULL){ |
||
405 | delete img;
|
||
406 | } |
||
407 | |||
408 | 3539 | nacho | } |