Statistics
| Revision:

svn-gvsig-desktop / branches / v02_desarrollo / libraries / libCq CMS for java.old / src / org / cresques / io / raster / RasterToImageFilter.java @ 1679

History | View | Annotate | Download (1.19 KB)

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