gvsig-raster / org.gvsig.raster.ermapper / trunk / org.gvsig.raster.ermapper / org.gvsig.raster.ermapper.jni / src / main / java / es / gva / cit / jecwcompress / NCSEcwCompressClient.java @ 2449
History | View | Annotate | Download (10.6 KB)
1 | 2449 | nbrodin | /**********************************************************************
|
---|---|---|---|
2 | * $Id: NCSEcwCompressClient.java 4274 2006-03-06 07:32:00Z nacho $
|
||
3 | *
|
||
4 | * Name: NCSEcwCompressClient.java
|
||
5 | * Project:
|
||
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.jecwcompress; |
||
52 | |||
53 | /**
|
||
54 | * Esta clase contiene las funciones para b�sicas para la compresi�n de Ecw. Para su uso
|
||
55 | * debe seguirse la secuencia de operaciones l�gica:
|
||
56 | * <UL>
|
||
57 | * <LI>Creaci�n de objeto de esta clase NCSEcwCompressClient</LI>
|
||
58 | * <LI>Asignaci�n de par�metros de compresi�n con las operaciones set</LI>
|
||
59 | * <LI>Crear una clase servidora de datos que implemente el interfaz ReadCallBack
|
||
60 | * y herede de JniObject</LI>
|
||
61 | * <LI>Hacer un open con NCSEcwCompressOpen</LI>
|
||
62 | * <LI>ejecutar el compresor con NCSEcwCompress y cerrar con NCSEcwCompressClose</LI>
|
||
63 | * </UL>
|
||
64 | *
|
||
65 | * @author Nacho Brodin <brodin_ign@gva.es>.<BR> Equipo de desarrollo gvSIG.<BR> http://www.gvsig.gva.es
|
||
66 | * @version 0.0
|
||
67 | * @link http://www.gvsig.gva.es
|
||
68 | */
|
||
69 | public class NCSEcwCompressClient extends JNIBase{ |
||
70 | |||
71 | private native long NCSEcwCompressClientNat(); |
||
72 | private native int NCSEcwCompressOpenNat(long cPtr, boolean bCalculateSizesOnly); |
||
73 | private native int NCSEcwCompressNat(long cPtr,ReadCallBack read); |
||
74 | private native int NCSEcwCompressCloseNat(long cPtr); |
||
75 | private native void NCSEcwCompressCancelNat(long cPtr); |
||
76 | private native void finalizeNat(long cPtr); |
||
77 | |||
78 | private String inputFilename=null; |
||
79 | private String outputFilename=null; |
||
80 | private double targetCompression=0.0; |
||
81 | private int eCompressFormat=0; |
||
82 | private int eCompressHint=0; |
||
83 | private int nBlockSizeX=0; |
||
84 | private int nBlockSizeY=0; |
||
85 | private int nInOutSizeX=0; |
||
86 | private int nInOutSizeY=0; |
||
87 | private int nInputBands=0; |
||
88 | private int nOutputBands=0; |
||
89 | private long nInputSize=0; |
||
90 | private double fCellIncrementX=0.0; |
||
91 | private double fCellIncrementY=0.0; |
||
92 | private double fOriginX=0.0; |
||
93 | private double fOriginY=0.0; |
||
94 | private int eCellSizeUnits=0; |
||
95 | private String szDatum=null; |
||
96 | private String szProjection=null; |
||
97 | private double fActualCompression=0.0; |
||
98 | private double fCompressionSeconds=0.0; |
||
99 | private double fCompressionMBSec=0.0; |
||
100 | private long nOutputSize=0; |
||
101 | |||
102 | public byte[] buffer; |
||
103 | private long readInfo; |
||
104 | private int porcentaje; |
||
105 | |||
106 | /**
|
||
107 | * Esta funci�n es llamada desde C para inicializar el buffer que contendr� 1 linea de datos
|
||
108 | */
|
||
109 | private void initialize(){ |
||
110 | buffer=new byte[nInOutSizeX*nInputBands]; |
||
111 | } |
||
112 | |||
113 | /**
|
||
114 | * Esta funci�n es llamada desde C para asignar la direcci�n de memoria de la estructura readInfo
|
||
115 | */
|
||
116 | private void setReadInfo(long ptr){ |
||
117 | readInfo=ptr; |
||
118 | } |
||
119 | |||
120 | /**
|
||
121 | * Esta funci�n es llamada desde C para recuperar la direcci�n de memoria de readInfo
|
||
122 | */
|
||
123 | private long getReadInfo(){ |
||
124 | return readInfo;
|
||
125 | } |
||
126 | |||
127 | /**
|
||
128 | * Devuelve la cantidad de imagen comprimida en tanto por cien.
|
||
129 | */
|
||
130 | public int getPercent(){ |
||
131 | return porcentaje;
|
||
132 | } |
||
133 | |||
134 | /**
|
||
135 | * Contructor
|
||
136 | * @throws EcwException Se produce cuando la llamada nativa devuelve un c�digo de error
|
||
137 | */
|
||
138 | public NCSEcwCompressClient()throws EcwException{ |
||
139 | |||
140 | cPtr = NCSEcwCompressClientNat(); |
||
141 | |||
142 | if(cPtr==0) |
||
143 | throw new EcwException("Error en la creaci�n del objeto NCSEcwCompressClient"); |
||
144 | } |
||
145 | |||
146 | /**
|
||
147 | * Inicializa el compresor
|
||
148 | * @throws EcwException Se produce cuando la llamada nativa devuelve un c�digo de error
|
||
149 | */
|
||
150 | public void NCSEcwCompressOpen(boolean bCalculateSizesOnly)throws EcwException{ |
||
151 | |||
152 | if(cPtr == 0) |
||
153 | throw new EcwException("Error en NCSEcwCompressOpen(). No hay una referencia v�lida al objeto NCSEcwCompressClient."); |
||
154 | |||
155 | int error = NCSEcwCompressOpenNat(cPtr, bCalculateSizesOnly);
|
||
156 | |||
157 | if(error == -1) |
||
158 | throw new EcwException("Error en NCSEcwCompressOpen(). No se ha podido obtener un objeto NCSEcwCompress valido"); |
||
159 | else if(error != 0) |
||
160 | throw new EcwException("Error en NCSEcwCompressOpen(). La llamada nativa ha devuelto un error "+NCSError.ErrorToString(error)); |
||
161 | |||
162 | } |
||
163 | |||
164 | /**
|
||
165 | * Realiza la funci�n de compresi�n
|
||
166 | * @throws EcwException Se produce cuando la llamada nativa devuelve un c�digo de error
|
||
167 | */
|
||
168 | public void NCSEcwCompress(ReadCallBack read)throws EcwException{ |
||
169 | |||
170 | if(cPtr == 0) |
||
171 | throw new EcwException("Error en NCSEcwCompress(). No hay una referencia v�lida al objeto NCSEcwCompressClient."); |
||
172 | |||
173 | if(read == null) |
||
174 | throw new EcwException("Error en NCSEcwCompress(). El par�metro ReadCallBack no puede ser nulo."); |
||
175 | |||
176 | int error = NCSEcwCompressNat(cPtr, read);
|
||
177 | |||
178 | if(error == -1) |
||
179 | throw new EcwException("Error en NCSEcwCompress(). No se ha podido obtener un objeto NCSEcwCompress valido"); |
||
180 | else if(error != 0) |
||
181 | throw new EcwException("Error en NCSEcwCompress(). La llamada nativa ha devuelto un error "+NCSError.ErrorToString(error)); |
||
182 | } |
||
183 | |||
184 | /**
|
||
185 | * Cierra el compresor
|
||
186 | * @throws EcwException Se produce cuando la llamada nativa devuelve un c�digo de error
|
||
187 | */
|
||
188 | public void NCSEcwCompressClose()throws EcwException{ |
||
189 | |||
190 | if(cPtr == 0) |
||
191 | throw new EcwException("Error en NCSEcwCompress(). No hay una referencia v�lida al objeto NCSEcwCompressClient."); |
||
192 | |||
193 | int error = NCSEcwCompressCloseNat(cPtr);
|
||
194 | |||
195 | if(error == -1) |
||
196 | throw new EcwException("Error en NCSEcwCompress(). No se ha podido obtener un objeto NCSEcwCompress valido"); |
||
197 | else if(error != 0) |
||
198 | throw new EcwException("Error en NCSEcwCompress(). La llamada nativa ha devuelto un error "+NCSError.ErrorToString(error)); |
||
199 | } |
||
200 | |||
201 | /**
|
||
202 | * Cancela la compresi�n
|
||
203 | * @throws EcwException Se produce cuando la llamada nativa devuelve un c�digo de error
|
||
204 | */
|
||
205 | public void NCSEcwCompressCancel()throws EcwException{ |
||
206 | |||
207 | if(cPtr == 0) |
||
208 | throw new EcwException("Error en NCSEcwCompress(). No hay una referencia v�lida al objeto NCSEcwCompressClient."); |
||
209 | |||
210 | NCSEcwCompressCancelNat(cPtr); |
||
211 | } |
||
212 | |||
213 | /**
|
||
214 | * @throws EcwException Se produce cuando la llamada nativa devuelve un c�digo de error
|
||
215 | */
|
||
216 | public void finalize()throws EcwException{ |
||
217 | |||
218 | if(cPtr == 0) |
||
219 | throw new EcwException("Error en finalize(). No hay una referencia v�lida al objeto NCSEcwCompressClient y no se ha podido liberar la memoria."); |
||
220 | |||
221 | //finalizeNat(cPtr);
|
||
222 | } |
||
223 | |||
224 | /**
|
||
225 | * Asigna el nombre del fichero de entrada
|
||
226 | * @param filename Nombre del fichero
|
||
227 | */
|
||
228 | public void setInputFilename(String filename){inputFilename=filename;}; |
||
229 | |||
230 | /**
|
||
231 | * Asigna el nombre del fichero de salida
|
||
232 | * @param filename Nombre del fichero
|
||
233 | */
|
||
234 | public void setOutputFilename(String filename){outputFilename=filename;}; |
||
235 | |||
236 | /**
|
||
237 | * Asigna el nivel de compresi�n
|
||
238 | * @param compress nivel de compresi�n
|
||
239 | */
|
||
240 | public void setTargetCompress(double compress){targetCompression=compress;}; |
||
241 | |||
242 | /**
|
||
243 | * Asigna el formato de compresi�n.
|
||
244 | * @param format formato de compresi�n. Los valores que puede tomar son:
|
||
245 | * <UL>
|
||
246 | * <LI>COMPRESS_NONE = NCSCS_NONE</LI>
|
||
247 | * <LI>COMPRESS_UINT8 = NCSCS_GREYSCALE</LI>
|
||
248 | * <LI>COMPRESS_YUV = NCSCS_YUV</LI>
|
||
249 | * <LI>COMPRESS_MULTI = NCSCS_MULTIBAND</LI>
|
||
250 | * <LI>COMPRESS_RGB = NCSCS_sRGB</LI>
|
||
251 | * </UL>
|
||
252 | */
|
||
253 | public void setCompressFormat(int format){eCompressFormat=format;}; |
||
254 | |||
255 | /**
|
||
256 | * Asigna el Compress Hint.
|
||
257 | * @param Compress hint. Los valores que puede tomar son:
|
||
258 | * <UL>
|
||
259 | * <LI>COMPRESS_HINT_NONE = 0</LI>
|
||
260 | * <LI>COMPRESS_HINT_FAST = 1</LI>
|
||
261 | * </LI>COMPRESS_HINT_BEST = 2</LI>
|
||
262 | * <LI>COMPRESS_HINT_INTERNET = 3</LI>
|
||
263 | * </UL>
|
||
264 | */
|
||
265 | public void setCompressHint(int hint){eCompressHint=hint;}; |
||
266 | |||
267 | /**
|
||
268 | * Asigna el tama�o de bloque en x
|
||
269 | * @param n tama�o de bloque en x
|
||
270 | */
|
||
271 | public void setBlockSizeX(int n){nBlockSizeX=n;}; |
||
272 | |||
273 | /**
|
||
274 | * Asigna el tama�o de bloque en y
|
||
275 | * @param n tama�o de bloque en y
|
||
276 | */
|
||
277 | public void setBlockSizeY(int n){nBlockSizeY=n;}; |
||
278 | |||
279 | /**
|
||
280 | * Asigna el tama�o de la imagen de salida en x
|
||
281 | * @param n tama�o de imagen de salida en x
|
||
282 | */
|
||
283 | public void setInOutSizeX(int n){nInOutSizeX=n;}; |
||
284 | |||
285 | /**
|
||
286 | * Asigna el tama�o de la imagen de salida en y
|
||
287 | * @param n tama�o de imagen de salida en y
|
||
288 | */
|
||
289 | public void setInOutSizeY(int n){nInOutSizeY=n;}; |
||
290 | |||
291 | /**
|
||
292 | * Asigna el n�mero de bandas de entrada
|
||
293 | * @param n N�mero de bandas de entrada
|
||
294 | */
|
||
295 | public void setInputBands(int n){nInputBands=n;}; |
||
296 | |||
297 | /**
|
||
298 | * Asigna el n�mero de bandas de salida
|
||
299 | * @param n N�mero de bandas de salida
|
||
300 | */
|
||
301 | public void setOutputBands(int n){nOutputBands=n;}; |
||
302 | |||
303 | public void setInputSize(long nis){nInputSize=nis;}; |
||
304 | public void setCellIncrementX(double x){fCellIncrementX=x;}; |
||
305 | public void setCellIncrementY(double y){fCellIncrementY=y;}; |
||
306 | public void setOriginX(double x){fOriginX=x;}; |
||
307 | public void setOriginY(double y){fOriginY=y;}; |
||
308 | |||
309 | /**
|
||
310 | * Asigna el tama�o de celda
|
||
311 | * @param cellu tama�o de celda. Puede tomar un valor entre los siguientes:
|
||
312 | * <UL>
|
||
313 | * <LI>ECW_CELL_UNITS_INVALID = 0</LI>
|
||
314 | * <LI>ECW_CELL_UNITS_METERS = 1</LI>
|
||
315 | * <LI>ECW_CELL_UNITS_DEGREES = 2</LI>
|
||
316 | * <LI>ECW_CELL_UNITS_FEET = 3</LI>
|
||
317 | * <LI>ECW_CELL_UNITS_UNKNOWN = 4</LI>
|
||
318 | * </UL>
|
||
319 | */
|
||
320 | public void setCellSizeUnits(int cellu){eCellSizeUnits=cellu;}; |
||
321 | |||
322 | /**
|
||
323 | * Asigna el datum
|
||
324 | * @param dat datum
|
||
325 | */
|
||
326 | public void setDatum(String dat){szDatum=dat;}; |
||
327 | |||
328 | /**
|
||
329 | * Asigna la proyecci�n
|
||
330 | * @param proj Proyecci�n
|
||
331 | */
|
||
332 | public void setProjection(String proj){szProjection=proj;}; |
||
333 | |||
334 | public void setActualCompression(double comp){fActualCompression=comp;}; |
||
335 | public void setCompressionSeconds(double comp){fCompressionSeconds=comp;}; |
||
336 | public void setCompressionMBSec(double comp){fCompressionMBSec=comp;}; |
||
337 | public void setOutputSize(long n){nOutputSize=n;}; |
||
338 | } |