svn-gvsig-desktop / branches / v05 / libraries / libjni-ecw / src-test / setView.java @ 34016
History | View | Annotate | Download (2.78 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 setView{ |
||
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 | |||
61 | double minX = ;
|
||
62 | double minY = ;
|
||
63 | double maxX = ;
|
||
64 | double maxY = ;
|
||
65 | |||
66 | System.out.println("ECW size = ("+file.width+","+file.height+")\n"+ |
||
67 | " datum='"+file.datum+"', proyeccion='"+file.projection+"'"); |
||
68 | |||
69 | System.out.println("origin="+file.originX+" "+file.originY); |
||
70 | System.out.println("cellIncrement="+file.cellIncrementX+" "+file.cellIncrementY); |
||
71 | System.out.println("Band List="+file.numBands); |
||
72 | |||
73 | try{
|
||
74 | File mifichero=new File("exit.raw"); |
||
75 | s = new FileOutputStream(mifichero); |
||
76 | }catch(Exception e){} |
||
77 | |||
78 | |||
79 | int bandlist[] = new int[file.numBands]; |
||
80 | for (int i=0; i< file.numBands; i++) { |
||
81 | bandlist[i] = i; |
||
82 | } |
||
83 | |||
84 | file.setView(file.numBands, bandlist, |
||
85 | minX, minY, maxX, maxY, |
||
86 | width, height); |
||
87 | |||
88 | int pRGBArray[] = new int[file.width]; |
||
89 | byte array[]= new byte[file.width]; |
||
90 | for (int line=0; line < file.height; line++) { |
||
91 | //System.out.println("line="+line);
|
||
92 | file.readLineRGBA(pRGBArray); |
||
93 | for (int i=0; i < pRGBArray.length ; i++)array[i]=(byte)pRGBArray[i]; |
||
94 | s.write(array); |
||
95 | } |
||
96 | |||
97 | |||
98 | file.close(true);
|
||
99 | System.out.println("END"); |
||
100 | s.close(); |
||
101 | while(true); |
||
102 | }catch(Exception e){e.printStackTrace();} |
||
103 | |||
104 | |||
105 | } |
||
106 | |||
107 | } |