Statistics
| Revision:

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

History | View | Annotate | Download (3.09 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;
27
import java.awt.image.BufferedImage;
28

    
29
import org.cresques.io.data.RasterBuf;
30

    
31

    
32
/**
33
 *
34
 * @author Nacho Brodin (brodin_ign@gva.es)
35
 */
36
public class RemoveBandsImageFilter extends RemoveBandsFilter {
37
    /**
38
     * Constructor
39
     *
40
     */
41
    public RemoveBandsImageFilter() {
42
        super();
43
    }
44

    
45
    /* (non-Javadoc)
46
     * @see org.cresques.io.raster.IRasterFilter#pre()
47
     */
48
    public void pre() {
49
        //Obtenci?n de par?metros
50
        this.image = (Image) params.get("raster");
51

    
52
        height = image.getHeight(null);
53
        width = image.getWidth(null);
54
        super.pre();
55
    }
56

    
57
    /* (non-Javadoc)
58
     * @see org.cresques.io.raster.IRasterFilter#process(int, int)
59
     */
60
    public void process(int col, int line) {
61
        int px = ((BufferedImage) image).getRGB(col, line);
62
        px = px & mascara;
63
        ((BufferedImage) image).setRGB(col, line, px);
64
    }
65

    
66
    /* (non-Javadoc)
67
     * @see org.cresques.io.raster.IRasterFilter#processSuperSampling(int, int)
68
     */
69
    public void processSuperSampling(int col, int line) {
70
             int px = ((BufferedImage) image).getRGB(col, line);
71
         px = px & mascara;
72
         for(int j = col; j < image.getWidth(null) && j < (col + stepX[contX + 1]); j++)
73
                         for(int i = line; i < image.getHeight(null) && i < (line + stepY[contY + 1]); i++)
74
                         ((BufferedImage) image).setRGB(j, i, px);
75
        }
76
    
77
    /* (non-Javadoc)
78
     * @see org.cresques.io.raster.IRasterFilter#getInRasterDataType()
79
     */
80
    public int getInRasterDataType() {
81
        return RasterBuf.TYPE_IMAGE;
82
    }
83

    
84
    /* (non-Javadoc)
85
     * @see org.cresques.io.raster.IRasterFilter#getOutRasterDataType()
86
     */
87
    public int getOutRasterDataType() {
88
        return RasterBuf.TYPE_IMAGE;
89
    }
90

    
91
    /* (non-Javadoc)
92
     * @see org.cresques.io.raster.IRasterFilter#post()
93
     */
94
    public void post() {
95
        super.post();
96
    }
97

    
98
    /* (non-Javadoc)
99
     * @see org.cresques.io.raster.RasterFilter#processLine(int)
100
     */
101
    public void processLine(int y) {
102
    }
103

    
104
    public Object getResult(String name) {
105
        if (name.equals("raster")) {
106
            return (Object) this.image;
107
        } else {
108
            return null;
109
        }
110
    }
111
}