Statistics
| Revision:

root / trunk / libraries / libjni-mrsid / src / main / java / es / gva / cit / jmrsid / LTISceneBuffer.java @ 20021

History | View | Annotate | Download (4.88 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 void FreeLTISceneBufferNat(long cPtr_LTISceneBuffer, long cPtr_tbuffer);
66
        
67
        public int size;
68
        public byte buf1[];
69
        public byte buf2[];
70
        public byte buf3[];
71
        public long cPtrbuffer;
72
        public boolean flag;
73
        
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(LTIPixel pixel, int totalNumCols, int totalNumRows, boolean flag)throws MrSIDException{
85
                 
86
                if(totalNumCols<0 || totalNumRows<0 || pixel==null)
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
                if(flag)cPtr=LTISceneBufferNat(pixel.cPtr, totalNumCols, totalNumRows, 1);
103
                else cPtr=LTISceneBufferNat(pixel.cPtr, totalNumCols, totalNumRows, 0);
104
                    
105
                if(cPtr<0)
106
                        throw new MrSIDException("Error en el constructor nativo LTIScene.");
107
        }
108
        
109
        /**
110
         * Constructor 
111
         * 
112
         * @param pixel        propiedades del pixel que ser?n usadas en el buffer
113
         * @param totalNumCols        ancho del buffer
114
         * @param totalNumRows        alto del buffer
115
         * @param colOffset posici?n X de la ventana
116
         * @param rowOffset posici?n Y de la ventana
117
         * @param windowNumCols Ancho de la ventana
118
         * @param windowNumRows Alto de la ventana
119
         * @param flag        Pone a null el puntero de datos si es false y llena el buffer si es true
120
         * @throws MrSIDException         
121
         */
122
        public LTISceneBuffer(LTIPixel pixel, int totalNumCols, int totalNumRows, int colOffset, int rowOffset, int windowNumCols, int windowNumRows, boolean flag)throws MrSIDException{
123
                 
124
                if(totalNumCols<0 || totalNumRows<0 || colOffset<0 || rowOffset<0 || windowNumCols<0 || windowNumRows<0 || pixel==null)
125
                        throw new MrSIDException("Valores no validos para el tama?o de ventana.");
126
                
127
                this.cPtrbuffer=-1;
128
                this.flag=flag;
129
                
130
                //Si el flag es 1 reservamos memoria para el buffer
131
                
132
                if(flag==true){                        
133
                        size=totalNumCols*totalNumRows;
134
                        buf1=new byte[size];
135
                        buf2=new byte[size];
136
                        buf3=new byte[size];
137
                        
138
                }
139
                
140
                if(flag)cPtr=LTISceneBuffer1Nat(pixel.cPtr, totalNumCols, totalNumRows, colOffset, rowOffset, windowNumCols, windowNumRows, 1);
141
                else cPtr=LTISceneBuffer1Nat(pixel.cPtr, totalNumCols, totalNumRows, colOffset, rowOffset, windowNumCols, windowNumRows, 0);
142
                    
143
                if(cPtr<0)
144
                        throw new MrSIDException("Error en el constructor nativo LTIScene.");
145
        }
146
        
147
        /**
148
         * Destructor 
149
         */
150
        public void finalize(){
151
                //System.out.println("Finalizando LTIsceneBuffer ..."+cPtrbuffer);
152
                if(cPtr > 0)
153
                        FreeLTISceneBufferNat(cPtr, cPtrbuffer);
154
        }
155
        
156
}