svn-gvsig-desktop / tags / v1_0_2_Build_902 / libraries / libjni-ecw / src-test / readEcw.java @ 43249
History | View | Annotate | Download (2.71 KB)
1 | 3538 | nacho | import java.awt.image.BufferedImage; |
---|---|---|---|
2 | import java.io.BufferedOutputStream; |
||
3 | import java.io.DataOutputStream; |
||
4 | import java.io.File; |
||
5 | import java.io.FileOutputStream; |
||
6 | |||
7 | import com.ermapper.ecw.JNCSFile; |
||
8 | |||
9 | /* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
||
10 | *
|
||
11 | * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
||
12 | *
|
||
13 | * This program is free software; you can redistribute it and/or
|
||
14 | * modify it under the terms of the GNU General Public License
|
||
15 | * as published by the Free Software Foundation; either version 2
|
||
16 | * of the License, or (at your option) any later version.
|
||
17 | *
|
||
18 | * This program is distributed in the hope that it will be useful,
|
||
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
21 | * GNU General Public License for more details.
|
||
22 | *
|
||
23 | * You should have received a copy of the GNU General Public License
|
||
24 | * along with this program; if not, write to the Free Software
|
||
25 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
||
26 | *
|
||
27 | * For more information, contact:
|
||
28 | *
|
||
29 | * Generalitat Valenciana
|
||
30 | * Conselleria d'Infraestructures i Transport
|
||
31 | * Av. Blasco Ib??ez, 50
|
||
32 | * 46010 VALENCIA
|
||
33 | * SPAIN
|
||
34 | *
|
||
35 | * +34 963862235
|
||
36 | * gvsig@gva.es
|
||
37 | * www.gvsig.gva.es
|
||
38 | *
|
||
39 | * or
|
||
40 | *
|
||
41 | * IVER T.I. S.A
|
||
42 | * Salamanca 50
|
||
43 | * 46005 Valencia
|
||
44 | * Spain
|
||
45 | *
|
||
46 | * +34 963163400
|
||
47 | * dac@iver.es
|
||
48 | */
|
||
49 | |||
50 | class readEcw{ |
||
51 | |||
52 | public static void main(String[] args){ |
||
53 | |||
54 | try{
|
||
55 | FileOutputStream s=null; |
||
56 | DataOutputStream midataOS=null; |
||
57 | BufferedOutputStream miBS=null; |
||
58 | |||
59 | JNCSFile file = new JNCSFile(args[0], false); |
||
60 | System.out.println("ECW size = ("+file.width+","+file.height+")\n"+ |
||
61 | " datum='"+file.datum+"', proyeccion='"+file.projection+"'"); |
||
62 | |||
63 | System.out.println("origin="+file.originX+" "+file.originY); |
||
64 | System.out.println("cellIncrement="+file.cellIncrementX+" "+file.cellIncrementY); |
||
65 | System.out.println("Band List="+file.numBands); |
||
66 | |||
67 | try{
|
||
68 | File mifichero=new File("exit.raw"); |
||
69 | s = new FileOutputStream(mifichero); |
||
70 | }catch(Exception e){} |
||
71 | |||
72 | |||
73 | int bandlist[] = new int[file.numBands]; |
||
74 | for (int i=0; i< file.numBands; i++) { |
||
75 | bandlist[i] = i; |
||
76 | } |
||
77 | |||
78 | file.setView(file.numBands, bandlist, |
||
79 | 0, 0, file.width-1, file.height-1, |
||
80 | file.width, file.height); |
||
81 | |||
82 | int pRGBArray[] = new int[file.width]; |
||
83 | byte array[]= new byte[file.width]; |
||
84 | for (int line=0; line < file.height; line++) { |
||
85 | //System.out.println("line="+line);
|
||
86 | file.readLineRGBA(pRGBArray); |
||
87 | for (int i=0; i < pRGBArray.length ; i++)array[i]=(byte)pRGBArray[i]; |
||
88 | s.write(array); |
||
89 | } |
||
90 | |||
91 | |||
92 | file.close(true);
|
||
93 | System.out.println("END"); |
||
94 | s.close(); |
||
95 | while(true); |
||
96 | }catch(Exception e){e.printStackTrace();} |
||
97 | |||
98 | |||
99 | } |
||
100 | |||
101 | } |