Revision 1679

View differences:

branches/v02_desarrollo/libraries/libCq CMS for java.old/src/org/cresques/io/raster/RasterToImageFilter.java
1
/*
2
 * Created on 25-feb-2005
3
 */
4
package org.cresques.io.raster;
5

  
6
import java.awt.Image;
7
import java.awt.image.BufferedImage;
8

  
9
/**
10
 * Renderiza el raster.
11
 * @author Luis W. Sevilla (sevilla_lui@gva.es)
12
 */
13

  
14
public class RasterToImageFilter extends RasterFilter {
15
	private BufferedImage image;
16
	private int alpha;
17
	private int rgb;
18
	public RasterToImageFilter(RasterBuf raster, int a) {
19
		super(raster, null);
20
		this.alpha = (a & 0xff) << 24;
21
		image = new BufferedImage(raster.getWidth(), raster.getHeight(), BufferedImage.TYPE_INT_ARGB);
22
		execute();
23
	}
24
	
25
	/* (non-Javadoc)
26
	 * @see org.cresques.px.PxRaster.RasterFilter#process(int, int)
27
	 */
28
	public void process(int x, int y) {
29
		raster.getPixelInt(x, y, px);
30
		rgb = alpha | ((px[0] & 0xff) << 16) |
31
				((px[1] & 0xff) << 8) | (px[2] & 0xff);
32
		
33
		image.setRGB(x, y, rgb);
34
	}
35
	
36
	public Image getImage() { return image; }
37

  
38
	/* (non-Javadoc)
39
	 * @see org.cresques.px.PxRaster.RasterFilter#processLines(int)
40
	 */
41
	public void processLine(int y) {
42
		for (int x=0; x<width; x++) {
43
			int [][] line = raster.getLineInt(y);
44
			rgb = alpha | ((line[x][0] & 0xff) << 16) |
45
				((line[x][1] & 0xff) << 8) | (line[x][2] & 0xff);
46
	
47
				image.setRGB(x, y, rgb);
48
		}
49
	}
50
}
51

  
0 52

  
branches/v02_desarrollo/libraries/libCq CMS for java.old/src/org/cresques/io/GeoRasterFile.java
71 71

  
72 72
	static {
73 73
		supportedExtensions = new TreeMap();
74
		if (System.getProperty("os.name").toUpperCase().startsWith("WIN")) {
74
		//if (System.getProperty("os.name").toUpperCase().startsWith("WIN")) {
75 75
			supportedExtensions.put("ecw",  EcwFile.class);
76
		}
76
		//}
77 77
		supportedExtensions.put("tif",  TifGeoRefFile.class);
78 78
		supportedExtensions.put("tiff", TifGeoRefFile.class);
79 79
		supportedExtensions.put("jpg",  TifGeoRefFile.class);
branches/v02_desarrollo/libraries/libCq CMS for java.old/src/org/cresques/px/PxRaster.java
9 9
import java.awt.Image;
10 10
import java.awt.geom.GeneralPath;
11 11
import java.awt.geom.Point2D;
12
import java.awt.image.DataBuffer;
12 13
import java.awt.image.ImageObserver;
13 14
import java.util.Date;
14 15
import java.util.Vector;
......
17 18
import org.cresques.cts.IProjection;
18 19
import org.cresques.geo.Projected;
19 20
import org.cresques.geo.ViewPortData;
20
//import org.cresques.io.GdalFile;
21
import org.cresques.io.GdalFile;
21 22
import org.cresques.io.GeoRasterFile;
22
//import org.cresques.io.raster.ComputeMinMaxFilter;
23
//import org.cresques.io.raster.ComputeMinMaxImageFilter;
24
//import org.cresques.io.raster.LinearEnhancementFilter;
25
//import org.cresques.io.raster.LinearEnhancementImageFilter;
26
//import org.cresques.io.raster.RasterBuf;
27
//import org.cresques.io.raster.RasterFilter;
28
//import org.cresques.io.raster.RasterStats;
23
import org.cresques.io.raster.ComputeMinMaxFilter;
24
import org.cresques.io.raster.ComputeMinMaxImageFilter;
25
import org.cresques.io.raster.LinearEnhancementFilter;
26
import org.cresques.io.raster.LinearEnhancementImageFilter;
27
import org.cresques.io.raster.RasterBuf;
28
import org.cresques.io.raster.RasterStats;
29
import org.cresques.io.raster.RasterToImageFilter;
29 30

  
30 31
public class PxRaster extends PxObj implements Projected {
31 32
	protected GeoRasterFile geoFile = null;
......
35 36
	protected GeoRasterFile [] colorBand = null;
36 37
	protected int rBand = 1, gBand = 2, bBand = 3;
37 38
	
38
	//RasterStats stats = new RasterStats();
39
	RasterStats stats = new RasterStats();
39 40
	int transparente = 0x10ffff80;
40 41

  
41 42
	String vName = null;
......
283 284
			System.out.println("Dibujando PxRaster: pt0 = "+pt);
284 285
			vp.mat.transform(pt, pt);
285 286
			System.out.println("Dibujando PxRaster: pt1 = "+pt);
286
			/*if (colorBand == null && geoFile instanceof GdalFile &&
287
			if (colorBand == null && geoFile instanceof GdalFile &&
287 288
				(geoFile.getDataType() != DataBuffer.TYPE_BYTE)) {
288 289
				System.out.println("PxRaster: Has dado con un Raster de 16 bits");
289 290
				System.out.println("Dibujando PxRaster sz=("+wImg+","+hImg+"...");
......
297 298
				g.drawImage(geoImage, (int) Math.round(pt.getX()), (int) Math.round(pt.getY()), component);
298 299
				t2 = new Date().getTime();
299 300
				System.out.println("Dibujando PxRaster: "+(t2-t1)/1000D+", secs. Dibujando");
300
			} else */if (colorBand != null) { // multiBands
301
			} else if (colorBand != null) { // multiBands
301 302
				System.out.println("Dibujando PxRaster (Multifile) ...");
302 303
    			//if (doTransparency)
303 304
    			//geoImage = new BufferedImage(wImg, hImg, BufferedImage.TYPE_INT_ARGB);
......
307 308
        		geoImage = colorBand[gBand].updateImage(wImg, hImg, rp, geoImage, GeoRasterFile.GREEN_BAND);
308 309
        		geoImage = colorBand[bBand].updateImage(wImg, hImg, rp, geoImage, GeoRasterFile.BLUE_BAND);
309 310

  
310
				//geoImage = renderizeRaster(geoImage);
311
				geoImage = renderizeRaster(geoImage);
311 312
        		g.drawImage(geoImage, (int) Math.round(pt.getX()), (int) Math.round(pt.getY()), component);
312 313
				t2 = new Date().getTime();
313 314
				System.out.println("Dibujando PxRaster: "+(t2-t1)/1000D+", secs.");
......
316 317
        		geoImage = geoFile.updateImage(wImg, hImg, rp);
317 318
				System.out.println("Dibujando PxRaster sz=("+wImg+","+hImg+"...");
318 319

  
319
				//geoImage = renderizeRaster(geoImage);
320
				geoImage = renderizeRaster(geoImage);
320 321
				g.drawImage(geoImage, (int) Math.round(pt.getX()), (int) Math.round(pt.getY()), component);
321 322
				t2 = new Date().getTime();
322 323
				System.out.println("Dibujando PxRaster: "+(t2-t1)/1000D+", secs.");
......
334 335
	
335 336
	
336 337
	
337
	/*	
338
	/**
339
	 * Renderiza el raster.
340
	 * @author Luis W. Sevilla (sevilla_lui@gva.es)
341
	 * /
338
	/* */	
342 339
	
343
	class RasterToImageFilter extends RasterFilter {
344
		private BufferedImage image;
345
		private int alpha;
346
		private int rgb;
347
		public RasterToImageFilter(RasterBuf raster, int a) {
348
			super(raster, null);
349
			this.alpha = (a & 0xff) << 24;
350
			image = new BufferedImage(raster.getWidth(), raster.getHeight(), BufferedImage.TYPE_INT_ARGB);
351
			execute();
352
		}
353
		
354
		/* (non-Javadoc)
355
		 * @see org.cresques.px.PxRaster.RasterFilter#process(int, int)
356
		 * /
357
		public void process(int x, int y) {
358
			raster.getPixelInt(x, y, px);
359
			rgb = alpha | ((px[0] & 0xff) << 16) |
360
					((px[1] & 0xff) << 8) | (px[2] & 0xff);
361
			
362
			image.setRGB(x, y, rgb);
363
		}
364
		
365
		public Image getImage() { return image; }
366

  
367
		/* (non-Javadoc)
368
		 * @see org.cresques.px.PxRaster.RasterFilter#processLines(int)
369
		 * /
370
		public void processLine(int y) {
371
			for (int x=0; x<width; x++) {
372
				int [][] line = raster.getLineInt(y);
373
				rgb = alpha | ((line[x][0] & 0xff) << 16) |
374
					((line[x][1] & 0xff) << 8) | (line[x][2] & 0xff);
375
		
376
					image.setRGB(x, y, rgb);
377
			}
378
		}
379
	}
380
	
381 340
	public Image renderizeRaster(RasterBuf raster) {
382 341
		if (true) {
383 342
			ComputeMinMaxFilter filter = 
......
414 373
			stats.pinta();
415 374
		return image;
416 375
	}
417
	*/
376
	/* */
418 377
	public void drawMarco(Graphics2D g, ViewPortData vp) {
419 378
//		Color color = new Color(255,222,165,128), fillColor = new Color(255,214,132,128);
420 379
		Color color = new Color(128,128,128), fillColor = new Color(255,220,220,0x20);
branches/v02_desarrollo/libraries/libCq CMS for java.old/src/org/cresques/cts/gt2/CSDatum.java
21 21
		"TOWGS84[0,0,0,0,0,0,0],AUTHORITY[\"EPSG\",\"6326\"]]";
22 22
	private static String line2 = "DATUM[\"European_Datum_1950\"," +
23 23
		"SPHEROID[\"International 1924\",6378388,297,AUTHORITY[\"EPSG\",\"7022\"]]," +
24
		"TOWGS84[-87,-98,-121,0,0,0,0],AUTHORITY[\"EPSG\",\"6230\"]]";
24
		"TOWGS84[-84,-107,-120,0,0,0,0],AUTHORITY[\"EPSG\",\"6230\"]]";
25 25
	private static String line3 = "DATUM[\"Nouvelle_Triangulation_Francaise\"," +
26 26
		"SPHEROID[\"Clarke 1880 (IGN)\",6378249.2,293.466021293627, AUTHORITY[\"EPSG\",\"7011\"]]," +
27 27
		"TOWGS84[-168,-60,320,0,0,0,0],AUTHORITY[\"EPSG\",\"6275\"]]";

Also available in: Unified diff