root / tags / v1_0_RELEASE / libraries / libjni-mrsid / src-test / Overviews.java @ 9167
History | View | Annotate | Download (4.22 KB)
1 |
/**********************************************************************
|
---|---|
2 |
* $Id: Overviews.java 9167 2006-12-04 16:01:24Z $
|
3 |
*
|
4 |
* Name: Overviews.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 |
import es.gva.cit.jmrsid.*; |
52 |
import java.io.*; |
53 |
|
54 |
/**
|
55 |
* Ejemplo de acceso a una overview de un mrsid. Accede a la imagen pasada como par?metro muestra
|
56 |
* alguna informaci?n y a partir de la ?ltima overview salva a .raw toda la imagen.
|
57 |
*
|
58 |
* @author Nacho Brodin <brodin_ign@gva.es>.<BR> Equipo de desarrollo gvSIG.<BR> http://www.gvsig.gva.es
|
59 |
* @version 0.0
|
60 |
* @link http://www.gvsig.gva.es
|
61 |
*/
|
62 |
public class Overviews { |
63 |
public static void main(String[] args){ |
64 |
|
65 |
LTIImageReader img; |
66 |
LTIMetadataDatabase metadata; |
67 |
LTIPixel pixel; |
68 |
int eColorSpace, nBands, eSampleType;
|
69 |
|
70 |
try{
|
71 |
img = new MrSIDImageReader(args[0]); |
72 |
img.initialize(); |
73 |
|
74 |
//Obtenemos algunos datos
|
75 |
|
76 |
int overviews = ((MrSIDImageReader)img).getNumLevels() ;
|
77 |
System.out.println("Overviews="+overviews); |
78 |
System.out.println("Width="+img.getWidth()); |
79 |
System.out.println("Height="+img.getHeight()); |
80 |
System.out.println("Stripsheigth="+img.getStripHeight()); |
81 |
nBands=img.getNumBands(); |
82 |
System.out.println("NumBands="+nBands); |
83 |
eColorSpace=img.getColorSpace(); |
84 |
System.out.println("ColorSpace="+eColorSpace); |
85 |
eSampleType=img.getDataType(); |
86 |
System.out.println("DataType="+eSampleType); |
87 |
pixel=new LTIPixel(eColorSpace, nBands, eSampleType);
|
88 |
double mag = ((LTIImage)img).getMinMagnification();
|
89 |
System.out.println("MinMagnification="+mag); |
90 |
|
91 |
System.out.println("Levels from min mag: " + ((MrSIDImageReader)img).getNumLevelsFromMinMagnification()); |
92 |
|
93 |
System.out.println("**************Zoom******************"); |
94 |
|
95 |
for(int i = 0; i < overviews ; i++){ |
96 |
double zoom = LTIUtils.levelToMag(i);
|
97 |
int[] dims=img.getDimsAtMag(zoom); |
98 |
System.out.println("Dims At overview "+ i +"= "+dims[0]+" "+dims[1]); |
99 |
System.out.println("Zoom="+zoom); |
100 |
} |
101 |
|
102 |
double zoom = LTIUtils.levelToMag(overviews);
|
103 |
int[] dims=img.getDimsAtMag(zoom); |
104 |
System.out.println("************************************"); |
105 |
|
106 |
//Creamos la escena con el tama?o del overview deseado
|
107 |
|
108 |
LTIScene scene=new LTIScene(0,0,dims[0],dims[1],zoom); |
109 |
LTISceneBuffer buffer=new LTISceneBuffer(pixel,dims[0],dims[1],true); |
110 |
((LTIImageStage)img).read(scene,buffer); |
111 |
|
112 |
FileOutputStream s=null; |
113 |
|
114 |
try{
|
115 |
File mifichero=new File("exit.raw"); |
116 |
s = new FileOutputStream(mifichero); |
117 |
}catch(Exception e){} |
118 |
|
119 |
|
120 |
try{
|
121 |
for(int j=0;j<buffer.size;j++){ |
122 |
s.write(buffer.buf1,j,1);
|
123 |
s.write(buffer.buf2,j,1);
|
124 |
s.write(buffer.buf3,j,1);
|
125 |
} |
126 |
}catch(IOException e){ |
127 |
System.out.println("Error writing a line in the file\n"); |
128 |
System.exit(1); |
129 |
} |
130 |
|
131 |
|
132 |
|
133 |
|
134 |
}catch(Exception e){ |
135 |
e.printStackTrace(); |
136 |
|
137 |
} |
138 |
|
139 |
|
140 |
|
141 |
} |
142 |
} |