svn-gvsig-desktop / tags / v1_0_RELEASE / libraries / libjni-mrsid / src / mrsidimagereader.cpp @ 9167
History | View | Annotate | Download (5.07 KB)
1 |
/**********************************************************************
|
---|---|
2 |
* $Id: mrsidimagereader.cpp 9167 2006-12-04 16:01:24Z $
|
3 |
*
|
4 |
* Name: mrsid_interfaz.c
|
5 |
* Project: JMRSID. Interfaz java to MrSID (Lizardtech).
|
6 |
* Purpose: dataset's Basic Funcions.
|
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 |
* [01] 01-Oct-2005 nbt MrSIDImageReaderArrayNat function to support name parameter in char array
|
51 |
*/
|
52 |
|
53 |
|
54 |
#include <jni.h> |
55 |
#include <stdlib.h> |
56 |
#include "es_gva_cit_jmrsid_MrSIDImageReader.h" |
57 |
#include "es_gva_cit_jmrsid_JNIBase.h" |
58 |
|
59 |
#include "lt_types.h" |
60 |
#include "lt_base.h" |
61 |
#include "lt_fileSpec.h" |
62 |
#include "lti_geoCoord.h" |
63 |
#include "lti_pixel.h" |
64 |
#include "lti_navigator.h" |
65 |
#include "lti_sceneBuffer.h" |
66 |
#include "lti_metadataDatabase.h" |
67 |
#include "lti_metadataRecord.h" |
68 |
#include "lti_utils.h" |
69 |
#include "MrSIDImageReader.h" |
70 |
#include "J2KImageReader.h" |
71 |
#include "lti_imageReader.h" |
72 |
#include "lti_sceneBuffer.h" |
73 |
#include "lti_scene.h" |
74 |
//#include "cpl_conv.h"
|
75 |
#include "TIFFImageWriter.h" |
76 |
|
77 |
LT_USE_NAMESPACE(LizardTech); |
78 |
|
79 |
/******************************************************************************/
|
80 |
// Constructor MrSIDImageReader
|
81 |
/******************************************************************************/
|
82 |
|
83 |
|
84 |
JNIEXPORT jlong JNICALL Java_es_gva_cit_jmrsid_MrSIDImageReader_MrSIDImageReaderNat |
85 |
(JNIEnv *env, jobject obj, jstring pszF){ |
86 |
|
87 |
const char *pszFilename; |
88 |
LTIImageReader *poImageReader; |
89 |
jlong jresult = 0 ;
|
90 |
FILE *fich; |
91 |
|
92 |
|
93 |
pszFilename = env->GetStringUTFChars(pszF, 0);
|
94 |
|
95 |
fich=fopen( pszFilename, "r" );
|
96 |
if( fich )
|
97 |
fclose(fich); |
98 |
else
|
99 |
{ |
100 |
fclose(fich); |
101 |
return -1; |
102 |
} |
103 |
|
104 |
const LTFileSpec fileSpec(pszFilename);
|
105 |
poImageReader = new MrSIDImageReader( fileSpec );
|
106 |
*(LTIImageReader **)&jresult = poImageReader; |
107 |
env->ReleaseStringUTFChars(pszF, pszFilename); |
108 |
|
109 |
|
110 |
if(poImageReader==NULL)return -1; |
111 |
else return jresult; |
112 |
|
113 |
} |
114 |
|
115 |
/******************************************************************************/
|
116 |
// Constructor MrSIDImageArrayReader
|
117 |
/******************************************************************************/
|
118 |
|
119 |
|
120 |
JNIEXPORT jlong JNICALL Java_es_gva_cit_jmrsid_MrSIDImageReader_MrSIDImageReaderArrayNat |
121 |
(JNIEnv *env, jobject obj, jbyteArray pszF){ |
122 |
|
123 |
char *pszFilename;
|
124 |
LTIImageReader *poImageReader; |
125 |
jlong jresult = 0 ;
|
126 |
FILE *fich; |
127 |
int longitud = 0; |
128 |
|
129 |
longitud = env->GetArrayLength(pszF); |
130 |
pszFilename = (char *)env->GetByteArrayElements(pszF, 0); |
131 |
pszFilename = (char *)realloc(pszFilename, longitud + 1); |
132 |
pszFilename[longitud] = '\0';
|
133 |
|
134 |
fich=fopen( (char *)pszFilename, "r" ); |
135 |
if( fich )
|
136 |
fclose(fich); |
137 |
else
|
138 |
return -1; |
139 |
|
140 |
const LTFileSpec fileSpec(pszFilename);
|
141 |
poImageReader = new MrSIDImageReader( fileSpec );
|
142 |
|
143 |
*(LTIImageReader **)&jresult = poImageReader; |
144 |
|
145 |
env->ReleaseByteArrayElements(pszF, (jbyte *)pszFilename, 0);
|
146 |
|
147 |
if(poImageReader==NULL) |
148 |
return -1; |
149 |
else
|
150 |
return jresult;
|
151 |
|
152 |
} |
153 |
|
154 |
/******************************************************************************/
|
155 |
// getNumLevels
|
156 |
/******************************************************************************/
|
157 |
|
158 |
JNIEXPORT jint JNICALL Java_es_gva_cit_jmrsid_JNIBase_getNumLevelsNat |
159 |
(JNIEnv *env, jobject obj, jlong cPtr){ |
160 |
|
161 |
MrSIDImageReader *img = (MrSIDImageReader *) 0 ;
|
162 |
int res = -1; |
163 |
|
164 |
img = *(MrSIDImageReader **)&cPtr; |
165 |
|
166 |
if(img!=NULL) |
167 |
res = img->getNumLevels(); |
168 |
|
169 |
return res;
|
170 |
|
171 |
} |
172 |
|
173 |
/******************************************************************************/
|
174 |
// ~MrSIDImageReader
|
175 |
/******************************************************************************/
|
176 |
|
177 |
JNIEXPORT void JNICALL Java_es_gva_cit_jmrsid_MrSIDImageReader_FreeMrSIDImageReaderNat
|
178 |
(JNIEnv *env, jobject obj, jlong cPtr){ |
179 |
|
180 |
MrSIDImageReader *reader = (MrSIDImageReader *) 0 ;
|
181 |
|
182 |
reader = *(MrSIDImageReader **)&cPtr; |
183 |
if(reader!=NULL){ |
184 |
delete reader;
|
185 |
} |
186 |
|
187 |
} |
188 |
|
189 |
|
190 |
|
191 |
|
192 |
|