svn-gvsig-desktop / tags / v1_9_Build_1250 / libraries / libjni-mrsid-macosx / src-test / Overviews4.java @ 33791
History | View | Annotate | Download (3.86 KB)
1 | 9099 | mija | /**********************************************************************
|
---|---|---|---|
2 | * $Id$
|
||
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 Overviews4 { |
||
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()-1; |
||
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 | |||
89 | System.out.println("**************Zoom******************"); |
||
90 | |||
91 | double zoom = LTIUtils.levelToMag(4); |
||
92 | int[] dims=img.getDimsAtMag(zoom); |
||
93 | System.out.println("Dims At overview "+overviews+"= "+dims[0]+" "+dims[1]); |
||
94 | System.out.println("Zoom="+zoom); |
||
95 | |||
96 | System.out.println("************************************"); |
||
97 | |||
98 | //Creamos la escena con el tama?o del overview deseado
|
||
99 | |||
100 | LTIScene scene=new LTIScene(0,0,dims[0],dims[1],zoom); |
||
101 | LTISceneBuffer buffer=new LTISceneBuffer(pixel,dims[0],dims[1],true); |
||
102 | ((LTIImageStage)img).read(scene,buffer); |
||
103 | |||
104 | FileOutputStream s=null; |
||
105 | |||
106 | try{
|
||
107 | File mifichero=new File("exit.raw"); |
||
108 | s = new FileOutputStream(mifichero); |
||
109 | }catch(Exception e){} |
||
110 | |||
111 | |||
112 | try{
|
||
113 | for(int j=0;j<buffer.size;j++){ |
||
114 | s.write(buffer.buf1,j,1);
|
||
115 | s.write(buffer.buf2,j,1);
|
||
116 | s.write(buffer.buf3,j,1);
|
||
117 | } |
||
118 | }catch(IOException e){ |
||
119 | System.out.println("Error writing a line in the file\n"); |
||
120 | System.exit(1); |
||
121 | } |
||
122 | |||
123 | |||
124 | |||
125 | |||
126 | }catch(Exception e){ |
||
127 | e.printStackTrace(); |
||
128 | |||
129 | } |
||
130 | |||
131 | |||
132 | |||
133 | } |
||
134 | } |