Statistics
| Revision:

svn-gvsig-desktop / trunk / libraries / libRaster / src / org / gvsig / raster / grid / filter / enhancement / BrightnessByteFilter.java @ 11076

History | View | Annotate | Download (2.38 KB)

1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2006 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 */
19
package org.gvsig.raster.grid.filter.enhancement;
20

    
21
import org.gvsig.raster.buffer.RasterBuffer;
22

    
23

    
24
/**
25
 * Filtro de brillo para buffer de datos tipo byte
26
 * @author Nacho Brodin (nachobrodin@gmail.com)
27
 *
28
 */
29
public class BrightnessByteFilter extends BrightnessFilter{
30
        
31
        public BrightnessByteFilter(){
32
                super();
33
        }
34
        
35
        public void pre(){
36
                exec = true;
37
                this.raster = (RasterBuffer) params.get("raster");
38
                height = raster.getHeight();
39
        width = raster.getWidth();
40
                this.incrBrillo = ((Integer) params.get("incrBrillo")).intValue();
41
                super.pre();
42
        }
43
        
44
        
45
        /*
46
         *  (non-Javadoc)
47
         * @see org.gvsig.fmap.grid.filter.IRasterFilter#process(int, int)
48
         */
49
        public void process(int col, int line) {
50
                
51
                for(int i = 0 ; i < raster.getBandCount() ; i++){
52
                        int p = (raster.getElemByte(line, col, i) & 0x000000ff);
53
                                
54
                        p += incrBrillo;
55
                        if(p > 255)
56
                                p = 255;
57
                        else if(p < 0)
58
                                p = 0;
59
                                                
60
                        raster.setElem(line, col, i, (byte)p);
61
                }
62
                
63
        }
64
        
65
        /*
66
         *  (non-Javadoc)
67
         * @see org.gvsig.fmap.grid.filter.IRasterFilter#getInRasterDataType()
68
         */
69
        public int getInRasterDataType() {
70
                return RasterBuffer.TYPE_BYTE;
71
        }
72

    
73
        /*
74
         *  (non-Javadoc)
75
         * @see org.gvsig.fmap.grid.filter.IRasterFilter#getOutRasterDataType()
76
         */
77
        public int getOutRasterDataType() {
78
                return RasterBuffer.TYPE_BYTE;
79
        }
80

    
81
        /*
82
         *  (non-Javadoc)
83
         * @see org.gvsig.fmap.grid.filter.IRasterFilter#getResult(java.lang.String)
84
         */
85
        public Object getResult(String name) {
86
                if (name.equals("raster")) {
87
            return (Object) this.raster;
88
        } else {
89
            return null;
90
        }
91
        }
92
        
93
}