gvsig-raster / org.gvsig.raster.cache / trunk / org.gvsig.raster.cache / org.gvsig.raster.cache.lib.impl / deprecated / buffer / test / io / TRWTIFFFullDataBuffer.java @ 1965
History | View | Annotate | Download (1.41 KB)
1 |
package org.gvsig.raster.cache.buffer.impl.io; |
---|---|
2 |
import java.io.IOException; |
3 |
|
4 |
import org.gvsig.jgdal.GdalException; |
5 |
|
6 |
/**
|
7 |
* Common use of TIFFRead and TIFFWrite class for read and save full data buffers.
|
8 |
*
|
9 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
10 |
*/
|
11 |
public class TRWTIFFFullDataBuffer { |
12 |
|
13 |
private String rasterOut = "/tmp/out.tif"; |
14 |
private String rasterIn = "./src/test/resources/image/001m09_1_0.tif"; |
15 |
//private String rasterIn = "/home/nacho/images1/MultiplesFicheros/ComunidadValenciana/p198r033_7t20010601_z31_nn10.tif";
|
16 |
public static void main(String[] args) { |
17 |
TRWTIFFFullDataBuffer t = new TRWTIFFFullDataBuffer();
|
18 |
t.save(); |
19 |
} |
20 |
|
21 |
public void save() { |
22 |
long t1 = System.currentTimeMillis(); |
23 |
|
24 |
GdalRead input = null;
|
25 |
GdalWrite out = null;
|
26 |
try {
|
27 |
input = new GdalRead(rasterIn);
|
28 |
Object data = input.readData(0, 0, input.getWidth(), input.getHeight()); |
29 |
|
30 |
out = new GdalWrite(rasterOut, input.getBandCount(), input.getDataType(), input.getWidth(), input.getHeight(), GdalWrite.COLOR_INTERP_RGB);
|
31 |
|
32 |
if(data instanceof byte[][]) { |
33 |
byte[][] d = (byte[][])data; |
34 |
out.writeByteBands(d); |
35 |
out.close(); |
36 |
} |
37 |
|
38 |
} catch (GdalException e) {
|
39 |
e.printStackTrace(); |
40 |
} catch (IOException e) { |
41 |
e.printStackTrace(); |
42 |
} catch (InterruptedException e) { |
43 |
e.printStackTrace(); |
44 |
} |
45 |
|
46 |
long t2 = System.currentTimeMillis(); |
47 |
System.out.println("Tiempo: " + (t2 - t1) + " milisegundos"); |
48 |
} |
49 |
|
50 |
} |