gvsig-raster / org.gvsig.raster.lizardtech / trunk / org.gvsig.raster.lizardtech / org.gvsig.raster.lizardtech.jni / src / main / java / es / gva / cit / jmrsid / LTISceneBuffer.java @ 1019
History | View | Annotate | Download (7.53 KB)
1 |
/**********************************************************************
|
---|---|
2 |
* $Id: LTISceneBuffer.java 3539 2006-01-09 12:23:20Z nacho $
|
3 |
*
|
4 |
* Name: LTISceneBuffer.java
|
5 |
* Project: JMRSID. Interface 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 |
package es.gva.cit.jmrsid; |
52 |
|
53 |
|
54 |
/**
|
55 |
* Buffer que contiene los datos de una escena.
|
56 |
*
|
57 |
* @author Nacho Brodin <brodin_ign@gva.es>.<BR> Equipo de desarrollo gvSIG.<BR> http://www.gvsig.gva.es
|
58 |
* @version 0.0
|
59 |
* @link http://www.gvsig.gva.es
|
60 |
*/
|
61 |
public class LTISceneBuffer extends JNIBase{ |
62 |
|
63 |
private native long LTISceneBufferNat(long pixel,int tamx,int tamy, int flag); |
64 |
private native long LTISceneBuffer1Nat(long pixel, int totalNumCols, int totalNumRows, int colOffset, int rowOffset, int windowNumCols, int windowNumRows, int flag); |
65 |
private native long LTISceneBuffer2Nat(long pixel, double x, double y, double w, double h, double mag, int totalNumCols, int totalNumRows, int flag); |
66 |
private native void FreeLTISceneBufferNat(long cPtr_LTISceneBuffer, long cPtr_tbuffer); |
67 |
|
68 |
public int size; |
69 |
public byte buf1[]; |
70 |
public byte buf2[]; |
71 |
public byte buf3[]; |
72 |
public long cPtrbuffer; |
73 |
public boolean flag; |
74 |
|
75 |
/**
|
76 |
* Constructor
|
77 |
*
|
78 |
* @param pixel propiedades del pixel que ser�n usadas en el buffer
|
79 |
* @param totalNumCols ancho del buffer
|
80 |
* @param totalNumRows alto del buffer
|
81 |
* @param flag Pone a null el puntero de datos si es false y llena el buffer si es true
|
82 |
* @throws MrSIDException
|
83 |
*/
|
84 |
public LTISceneBuffer(int totalNumCols, int totalNumRows, boolean flag)throws MrSIDException{ |
85 |
|
86 |
if(totalNumCols < 0 || totalNumRows < 0) |
87 |
throw new MrSIDException("Valores no validos para el tama�o de ventana."); |
88 |
|
89 |
this.cPtrbuffer = -1; |
90 |
this.flag = flag;
|
91 |
|
92 |
//Si el flag es true reservamos memoria para el buffer
|
93 |
|
94 |
if(flag==true) { |
95 |
size = totalNumCols * totalNumRows; |
96 |
buf1 = new byte[size]; |
97 |
buf2 = new byte[size]; |
98 |
buf3 = new byte[size]; |
99 |
} |
100 |
} |
101 |
|
102 |
/**
|
103 |
* Constructor
|
104 |
*
|
105 |
* @param pixel propiedades del pixel que ser�n usadas en el buffer
|
106 |
* @param totalNumCols ancho del buffer
|
107 |
* @param totalNumRows alto del buffer
|
108 |
* @param flag Pone a null el puntero de datos si es false y llena el buffer si es true
|
109 |
* @throws MrSIDException
|
110 |
*/
|
111 |
public LTISceneBuffer(LTIPixel pixel, double x, double y, double w, double h, double magnification, int totalNumCols, int totalNumRows, boolean flag)throws MrSIDException{ |
112 |
|
113 |
if(totalNumCols < 0 || totalNumRows < 0 || pixel == null) |
114 |
throw new MrSIDException("Valores no validos para el tama�o de ventana."); |
115 |
|
116 |
this.cPtrbuffer = -1; |
117 |
this.flag = flag;
|
118 |
|
119 |
//Si el flag es true reservamos memoria para el buffer
|
120 |
|
121 |
if(flag==true) { |
122 |
size = totalNumCols * totalNumRows; |
123 |
buf1 = new byte[size]; |
124 |
buf2 = new byte[size]; |
125 |
buf3 = new byte[size]; |
126 |
} |
127 |
|
128 |
if(flag)
|
129 |
cPtr = LTISceneBuffer2Nat(pixel.cPtr, x, y, w, h, magnification, totalNumCols, totalNumRows, 1);
|
130 |
else
|
131 |
cPtr = LTISceneBuffer2Nat(pixel.cPtr, x, y, w, h, magnification, totalNumCols, totalNumRows, 0);
|
132 |
|
133 |
if(cPtr == 0) |
134 |
throw new MrSIDException("Error en el constructor nativo LTIScene."); |
135 |
} |
136 |
|
137 |
/**
|
138 |
* Constructor
|
139 |
*
|
140 |
* @param pixel propiedades del pixel que ser�n usadas en el buffer
|
141 |
* @param totalNumCols ancho del buffer
|
142 |
* @param totalNumRows alto del buffer
|
143 |
* @param flag Pone a null el puntero de datos si es false y llena el buffer si es true
|
144 |
* @throws MrSIDException
|
145 |
*/
|
146 |
public LTISceneBuffer(LTIPixel pixel, int totalNumCols, int totalNumRows, boolean flag)throws MrSIDException{ |
147 |
|
148 |
if(totalNumCols<0 || totalNumRows<0 || pixel==null) |
149 |
throw new MrSIDException("Valores no validos para el tama�o de ventana."); |
150 |
|
151 |
this.cPtrbuffer=-1; |
152 |
this.flag=flag;
|
153 |
|
154 |
//Si el flag es true reservamos memoria para el buffer
|
155 |
|
156 |
if(flag==true){ |
157 |
size=totalNumCols*totalNumRows; |
158 |
buf1=new byte[size]; |
159 |
buf2=new byte[size]; |
160 |
buf3=new byte[size]; |
161 |
|
162 |
} |
163 |
|
164 |
if(flag)cPtr=LTISceneBufferNat(pixel.cPtr, totalNumCols, totalNumRows, 1); |
165 |
else cPtr=LTISceneBufferNat(pixel.cPtr, totalNumCols, totalNumRows, 0); |
166 |
|
167 |
if(cPtr == 0) |
168 |
throw new MrSIDException("Error en el constructor nativo LTIScene."); |
169 |
} |
170 |
|
171 |
/**
|
172 |
* Constructor
|
173 |
*
|
174 |
* @param pixel propiedades del pixel que ser�n usadas en el buffer
|
175 |
* @param totalNumCols ancho del buffer
|
176 |
* @param totalNumRows alto del buffer
|
177 |
* @param colOffset posici�n X de la ventana
|
178 |
* @param rowOffset posici�n Y de la ventana
|
179 |
* @param windowNumCols Ancho de la ventana
|
180 |
* @param windowNumRows Alto de la ventana
|
181 |
* @param flag Pone a null el puntero de datos si es false y llena el buffer si es true
|
182 |
* @throws MrSIDException
|
183 |
*/
|
184 |
public LTISceneBuffer(LTIPixel pixel, int totalNumCols, int totalNumRows, int colOffset, int rowOffset, int windowNumCols, int windowNumRows, boolean flag)throws MrSIDException{ |
185 |
|
186 |
/*if ((colOffset < 0) || (rowOffset < 0) || (colOffset > baseSimpleFunction(3, "", "")) || (colOffset > baseSimpleFunction(4, "", "")))
|
187 |
throw new MrSIDException("Posicion inicial de la escena no valida");
|
188 |
|
189 |
if ((windowNumCols < 1) || (windowNumRows < 1) || (windowNumCols > baseSimpleFunction(3, "", "")) || (windowNumRows > baseSimpleFunction(4, "", "")))
|
190 |
throw new MrSIDException("Tama�o de la escena no valido");
|
191 |
|
192 |
if (((colOffset + windowNumCols) > baseSimpleFunction(3, "", "")) || ((rowOffset + windowNumRows) > baseSimpleFunction(4, "", "")))
|
193 |
throw new MrSIDException("Valores de la escena no validos");
|
194 |
|
195 |
if(totalNumCols<0 || totalNumRows<0 || pixel==null)
|
196 |
throw new MrSIDException("Valores no validos para el tama�o de ventana.");
|
197 |
*/
|
198 |
this.cPtrbuffer=-1; |
199 |
this.flag=flag;
|
200 |
|
201 |
//Si el flag es 1 reservamos memoria para el buffer
|
202 |
|
203 |
if(flag==true){ |
204 |
size=totalNumCols*totalNumRows; |
205 |
buf1=new byte[size]; |
206 |
buf2=new byte[size]; |
207 |
buf3=new byte[size]; |
208 |
|
209 |
} |
210 |
|
211 |
if(flag)cPtr=LTISceneBuffer1Nat(pixel.cPtr, totalNumCols, totalNumRows, colOffset, rowOffset, windowNumCols, windowNumRows, 1); |
212 |
else cPtr=LTISceneBuffer1Nat(pixel.cPtr, totalNumCols, totalNumRows, colOffset, rowOffset, windowNumCols, windowNumRows, 0); |
213 |
|
214 |
if(cPtr == 0) |
215 |
throw new MrSIDException("Error en el constructor nativo LTIScene."); |
216 |
} |
217 |
|
218 |
/**
|
219 |
* Destructor
|
220 |
*/
|
221 |
public void finalize(){ |
222 |
//System.out.println("Finalizando LTIsceneBuffer ..."+cPtrbuffer);
|
223 |
if(cPtr != 0) |
224 |
FreeLTISceneBufferNat(cPtr, cPtrbuffer); |
225 |
} |
226 |
|
227 |
} |