gvsig-raster / org.gvsig.raster.lizardtech / trunk / org.gvsig.raster.lizardtech / org.gvsig.raster.lizardtech.jni / src / main / native / jmrsid / mrsidimagereader.cpp @ 2452
History | View | Annotate | Download (5.03 KB)
1 |
/**********************************************************************
|
---|---|
2 |
* $Id: mrsidimagereader.cpp 8460 2006-10-31 16:26:34Z nacho $
|
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 |
#include "lt_fileSpec.h" |
59 |
#include "MrSIDImageReader.h" |
60 |
|
61 |
LT_USE_NAMESPACE(LizardTech); |
62 |
|
63 |
/******************************************************************************/
|
64 |
// Constructor MrSIDImageReader
|
65 |
/******************************************************************************/
|
66 |
|
67 |
|
68 |
JNIEXPORT jlong JNICALL Java_es_gva_cit_jmrsid_MrSIDImageReader_MrSIDImageReaderNat |
69 |
(JNIEnv *env, jobject obj, jstring pszF){ |
70 |
|
71 |
const char *pszFilename; |
72 |
MrSIDImageReader *poImageReader; |
73 |
jlong jresult = 0 ;
|
74 |
FILE *fich; |
75 |
|
76 |
|
77 |
pszFilename = env->GetStringUTFChars(pszF, 0);
|
78 |
|
79 |
fich=fopen( pszFilename, "r" );
|
80 |
if( fich )
|
81 |
fclose(fich); |
82 |
else
|
83 |
{ |
84 |
fclose(fich); |
85 |
return -1; |
86 |
} |
87 |
|
88 |
const LTFileSpec fileSpec(pszFilename);
|
89 |
poImageReader = MrSIDImageReader::create(); |
90 |
poImageReader->initialize(fileSpec); |
91 |
|
92 |
//poImageReader = new MrSIDImageReader( fileSpec );
|
93 |
//*(LTIImageReader **)&jresult = poImageReader;
|
94 |
|
95 |
*(MrSIDImageReader **)&jresult = poImageReader; |
96 |
env->ReleaseStringUTFChars(pszF, pszFilename); |
97 |
|
98 |
|
99 |
if(poImageReader==NULL)return -1; |
100 |
else return jresult; |
101 |
|
102 |
} |
103 |
|
104 |
/******************************************************************************/
|
105 |
// Constructor MrSIDImageArrayReader
|
106 |
/******************************************************************************/
|
107 |
|
108 |
|
109 |
JNIEXPORT jlong JNICALL Java_es_gva_cit_jmrsid_MrSIDImageReader_MrSIDImageReaderArrayNat |
110 |
(JNIEnv *env, jobject obj, jbyteArray pszF){ |
111 |
|
112 |
jbyte *aux = NULL;
|
113 |
jbyte *pszFilename; |
114 |
MrSIDImageReader *poImageReader; |
115 |
jlong jresult = 0 ;
|
116 |
FILE *fich; |
117 |
int longitud = 0; |
118 |
|
119 |
longitud = env->GetArrayLength(pszF); |
120 |
pszFilename = (jbyte *)env->GetByteArrayElements(pszF, 0);
|
121 |
|
122 |
aux = (jbyte *)malloc(sizeof(jbyte) * (longitud + 1)); |
123 |
memcpy(aux, pszFilename, longitud); |
124 |
env->ReleaseByteArrayElements(pszF, (jbyte *)pszFilename, 0);
|
125 |
pszFilename = aux; |
126 |
|
127 |
pszFilename[longitud] = '\0';
|
128 |
|
129 |
fich=fopen( (char *)pszFilename, "r" ); |
130 |
if( fich )
|
131 |
fclose(fich); |
132 |
else
|
133 |
return -1; |
134 |
|
135 |
const LTFileSpec fileSpec((char *)pszFilename); |
136 |
poImageReader = MrSIDImageReader::create(); |
137 |
poImageReader->initialize(fileSpec); |
138 |
|
139 |
*(MrSIDImageReader **)&jresult = poImageReader; |
140 |
|
141 |
free(pszFilename); |
142 |
|
143 |
if(poImageReader==NULL) |
144 |
return -1; |
145 |
else
|
146 |
return jresult;
|
147 |
|
148 |
} |
149 |
|
150 |
/******************************************************************************/
|
151 |
// getNumLevels
|
152 |
/******************************************************************************/
|
153 |
|
154 |
JNIEXPORT jint JNICALL Java_es_gva_cit_jmrsid_JNIBase_getNumLevelsNat |
155 |
(JNIEnv *env, jobject obj, jlong cPtr){ |
156 |
|
157 |
MrSIDImageReader *img = (MrSIDImageReader *) 0 ;
|
158 |
int res = -1; |
159 |
|
160 |
img = *(MrSIDImageReader **)&cPtr; |
161 |
|
162 |
if(img!=NULL) |
163 |
res = img->getNumLevels(); |
164 |
|
165 |
return res;
|
166 |
|
167 |
} |
168 |
|
169 |
/******************************************************************************/
|
170 |
// ~MrSIDImageReader
|
171 |
/******************************************************************************/
|
172 |
|
173 |
JNIEXPORT void JNICALL Java_es_gva_cit_jmrsid_MrSIDImageReader_FreeMrSIDImageReaderNat
|
174 |
(JNIEnv *env, jobject obj, jlong cPtr){ |
175 |
|
176 |
/*MrSIDImageReader *reader = (MrSIDImageReader *) 0 ;
|
177 |
|
178 |
reader = *(MrSIDImageReader **)&cPtr;
|
179 |
if(reader!=NULL){
|
180 |
delete reader;
|
181 |
}*/
|
182 |
|
183 |
} |
184 |
|
185 |
|
186 |
|
187 |
|
188 |
|