Statistics
| Revision:

root / trunk / libraries / libCq_CMS_praster / src / org / cresques / filter / bands / RasterIntToImageFilter.java @ 8026

History | View | Annotate | Download (3.59 KB)

1
/*
2
 * Cresques Mapping Suite. Graphic Library for constructing mapping applications.
3
 *
4
 * Copyright (C) 2004-5.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
 *
20
 * For more information, contact:
21
 *
22
 * cresques@gmail.com
23
 */
24
package org.cresques.filter.bands;
25

    
26
import java.awt.image.BufferedImage;
27

    
28
import org.cresques.filter.RasterFilter;
29
import org.cresques.io.data.RasterBuf;
30

    
31

    
32
/**
33
 * Renderiza el raster.
34
 * @author Luis W. Sevilla (sevilla_lui@gva.es)
35
 */
36
public class RasterIntToImageFilter extends RasterToImageFilter {
37
        private int[]                 px = {0, 0, 0, 255};
38
         
39
    /**
40
     * Constructor
41
     *
42
     */
43
    public RasterIntToImageFilter() {
44
    }
45

    
46
    /* (non-Javadoc)
47
     * @see org.cresques.io.raster.IRasterFilter#pre()
48
     */
49
    public void pre() {
50
       super.pre();
51
    }
52

    
53
    /* (non-Javadoc)
54
     * @see org.cresques.px.PxRaster.RasterFilter#process(int, int)
55
     */
56
    public void process(int col, int line) {
57
        raster.getElemInt(line, col, px);
58
        rgb = (alpha & ((((int)255) & 0xff) << 24)) | ((px[0] & 0xff) << 16) |
59
              ((px[1] & 0xff) << 8) | (px[2] & 0xff);
60
        /*rgb = (alpha & ((px[3] & 0xff) << 24)) | ((px[0] & 0xff) << 16) |
61
        ((px[1] & 0xff) << 8) | (px[2] & 0xff);*/
62

    
63
        image.setRGB(col, line, rgb);
64
    }
65
    
66
        public void processSuperSampling(int col, int line){
67
                raster.getElemInt(line, col, px);
68
        rgb = (alpha & ((((int)255) & 0xff) << 24)) | ((px[0] & 0xff) << 16) |
69
              ((px[1] & 0xff) << 8) | (px[2] & 0xff);
70
        /*rgb = (alpha & ((px[3] & 0xff) << 24)) | ((px[0] & 0xff) << 16) |
71
        ((px[1] & 0xff) << 8) | (px[2] & 0xff);*/
72
        
73
        for(int j = col; j < raster.getWidth() && j < (col + stepX[contX + 1]); j++)
74
                        for(int i = line; i < raster.getHeight() && i < (line + stepY[contY + 1]); i++)
75
                                image.setRGB(j, i, rgb);
76
        }
77

    
78
    /* (non-Javadoc)
79
     * @see org.cresques.io.raster.IRasterFilter#getResult(java.lang.String)
80
     */
81
    public Object getResult(String name) {
82
        return super.getResult(name);
83
    }
84

    
85
    /* (non-Javadoc)
86
     * @see org.cresques.px.PxRaster.RasterFilter#processLines(int)
87
     */
88
    public void processLine(int y) {
89
        for (int x = 0; x < width; x++) {
90
            int[][] line = raster.getLineInt(y);
91
            rgb = (alpha & ((px[3] & 0xff) << 24)) |
92
                  ((line[x][0] & 0xff) << 16) | ((line[x][1] & 0xff) << 8) |
93
                  (line[x][2] & 0xff);
94

    
95
            image.setRGB(x, y, rgb);
96
        }
97
    }
98

    
99
    /* (non-Javadoc)
100
     * @see org.cresques.io.raster.IRasterFilter#getInRasterDataType()
101
     */
102
    public int getInRasterDataType() {
103
        return super.getInRasterDataType();
104
    }
105

    
106
    /* (non-Javadoc)
107
     * @see org.cresques.io.raster.IRasterFilter#getOutRasterDataType()
108
     */
109
    public int getOutRasterDataType() {
110
        return super.getOutRasterDataType();
111
    }
112

    
113
    /* (non-Javadoc)
114
     * @see org.cresques.io.raster.IRasterFilter#post()
115
     */
116
    public void post() {
117
            super.post();
118
    }
119
}