root / trunk / libraries / libjni-mrsid / src / es / gva / cit / jmrsid / LTISceneBuffer.java @ 1180
History | View | Annotate | Download (4.36 KB)
1 |
/**********************************************************************
|
---|---|
2 |
* $Id: LTISceneBuffer.java 1180 2005-01-25 12:04:45Z igbrotru $
|
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 |
/*Copyright (C) 2004 Nacho Brodin <brodin_ign@gva.es>
|
11 |
|
12 |
This program is free software; you can redistribute it and/or
|
13 |
modify it under the terms of the GNU General Public License
|
14 |
as published by the Free Software Foundation; either version 2
|
15 |
of the License, or (at your option) any later version.
|
16 |
|
17 |
This program is distributed in the hope that it will be useful,
|
18 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
19 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
20 |
GNU General Public License for more details.
|
21 |
|
22 |
You should have received a copy of the GNU General Public License
|
23 |
along with this program; if not, write to the Free Software
|
24 |
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
25 |
*/
|
26 |
|
27 |
package es.gva.cit.jmrsid; |
28 |
|
29 |
|
30 |
/**
|
31 |
* @author Nacho Brodin <brodin_ign@gva.es>.<BR> Equipo de desarrollo gvSIG.<BR> http://www.gvsig.gva.es
|
32 |
* @version 0.0
|
33 |
* @link http://www.gvsig.gva.es
|
34 |
*/
|
35 |
|
36 |
public class LTISceneBuffer extends JNIBase{ |
37 |
|
38 |
private native long LTISceneBufferNat(long pixel,int tamx,int tamy, int flag); |
39 |
private native long LTISceneBuffer1Nat(long pixel, int totalNumCols, int totalNumRows, int colOffset, int rowOffset, int windowNumCols, int windowNumRows, int flag); |
40 |
private native void FreeLTISceneBufferNat(long cPtr_LTISceneBuffer, long cPtr_tbuffer); |
41 |
|
42 |
public int size; |
43 |
public byte buf1[]; |
44 |
public byte buf2[]; |
45 |
public byte buf3[]; |
46 |
public long cPtrbuffer; |
47 |
public boolean flag; |
48 |
|
49 |
|
50 |
/**
|
51 |
* Constructor
|
52 |
*
|
53 |
* @param pixel propiedades del pixel que ser?n usadas en el buffer
|
54 |
* @param totalNumCols ancho del buffer
|
55 |
* @param totalNumRows alto del buffer
|
56 |
* @param flag Pone a null el puntero de datos si es false y llena el buffer si es true
|
57 |
* @throws MrSIDException
|
58 |
*/
|
59 |
|
60 |
public LTISceneBuffer(LTIPixel pixel, int totalNumCols, int totalNumRows, boolean flag)throws MrSIDException{ |
61 |
|
62 |
if(totalNumCols<0 || totalNumRows<0 || pixel==null) |
63 |
throw new MrSIDException("Valores no validos para el tama?o de ventana."); |
64 |
|
65 |
this.cPtrbuffer=-1; |
66 |
this.flag=flag;
|
67 |
|
68 |
//Si el flag es true reservamos memoria para el buffer
|
69 |
|
70 |
if(flag==true){ |
71 |
size=totalNumCols*totalNumRows; |
72 |
buf1=new byte[size]; |
73 |
buf2=new byte[size]; |
74 |
buf3=new byte[size]; |
75 |
|
76 |
} |
77 |
|
78 |
if(flag)cPtr=LTISceneBufferNat(pixel.cPtr, totalNumCols, totalNumRows, 1); |
79 |
else cPtr=LTISceneBufferNat(pixel.cPtr, totalNumCols, totalNumRows, 0); |
80 |
|
81 |
if(cPtr<0) |
82 |
throw new MrSIDException("Error en el constructor nativo LTIScene."); |
83 |
} |
84 |
|
85 |
/**
|
86 |
* Constructor
|
87 |
*
|
88 |
* @param pixel propiedades del pixel que ser?n usadas en el buffer
|
89 |
* @param totalNumCols ancho del buffer
|
90 |
* @param totalNumRows alto del buffer
|
91 |
* @param colOffset posici?n X de la ventana
|
92 |
* @param rowOffset posici?n Y de la ventana
|
93 |
* @param windowNumCols Ancho de la ventana
|
94 |
* @param windowNumRows Alto de la ventana
|
95 |
* @param flag Pone a null el puntero de datos si es false y llena el buffer si es true
|
96 |
* @throws MrSIDException
|
97 |
*/
|
98 |
|
99 |
public LTISceneBuffer(LTIPixel pixel, int totalNumCols, int totalNumRows, int colOffset, int rowOffset, int windowNumCols, int windowNumRows, boolean flag)throws MrSIDException{ |
100 |
|
101 |
if(totalNumCols<0 || totalNumRows<0 || colOffset<0 || rowOffset<0 || windowNumCols<0 || windowNumRows<0 || pixel==null) |
102 |
throw new MrSIDException("Valores no validos para el tama?o de ventana."); |
103 |
|
104 |
this.cPtrbuffer=-1; |
105 |
this.flag=flag;
|
106 |
|
107 |
//Si el flag es 1 reservamos memoria para el buffer
|
108 |
|
109 |
if(flag==true){ |
110 |
size=totalNumCols*totalNumRows; |
111 |
buf1=new byte[size]; |
112 |
buf2=new byte[size]; |
113 |
buf3=new byte[size]; |
114 |
|
115 |
} |
116 |
|
117 |
if(flag)cPtr=LTISceneBuffer1Nat(pixel.cPtr, totalNumCols, totalNumRows, colOffset, rowOffset, windowNumCols, windowNumRows, 1); |
118 |
else cPtr=LTISceneBuffer1Nat(pixel.cPtr, totalNumCols, totalNumRows, colOffset, rowOffset, windowNumCols, windowNumRows, 0); |
119 |
|
120 |
if(cPtr<0) |
121 |
throw new MrSIDException("Error en el constructor nativo LTIScene."); |
122 |
} |
123 |
|
124 |
/**
|
125 |
* Destructor
|
126 |
*/
|
127 |
|
128 |
public void finalize(){ |
129 |
System.out.println("Finalizando LTIsceneBuffer ..."+cPtrbuffer); |
130 |
if(cPtr > 0) |
131 |
FreeLTISceneBufferNat(cPtr, cPtrbuffer); |
132 |
} |
133 |
|
134 |
} |