Statistics
| Revision:

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

History | View | Annotate | Download (2.71 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. En el m?todo de proceso 
26
 * procesa un solo pixel byte e incrementa su brillo en la cantidad indicada en 
27
 * la variable incrBrillo.
28
 * 
29
 * @author Miguel ?ngel Querol Carratal?  (miguelangel.querol@iver.es)
30
 *
31
 */
32
public class BrightnessByteFilter extends BrightnessFilter{
33
        
34
        /**
35
         * Constructor. LLama al constructor base de los filtros de 
36
         * brillo.
37
         */
38
        public BrightnessByteFilter(){
39
                super();
40
        }
41
        
42
        /*
43
         * (non-Javadoc)
44
         * @see org.gvsig.raster.grid.filter.enhancement.BrightnessFilter#pre()
45
         */
46
        public void pre(){
47
                exec = true;
48
                this.raster = (RasterBuffer) params.get("raster");
49
                height = raster.getHeight();
50
        width = raster.getWidth();
51
                this.incrBrillo = ((Integer) params.get("incrBrillo")).intValue();
52
                super.pre();
53
        }
54
        
55
        /*
56
         *  (non-Javadoc)
57
         * @see org.gvsig.fmap.grid.filter.IRasterFilter#process(int, int)
58
         */
59
        public void process(int col, int line) {
60
                
61
                for (int i = 0; i < raster.getBandCount(); i++) {
62
                        int p = (raster.getElemByte(line, col, i) & 0x000000ff);
63

    
64
                        p += incrBrillo;
65
                        if (p > 255)
66
                                p = 255;
67
                        else if (p < 0)
68
                                p = 0;
69

    
70
                        raster.setElem(line, col, i, (byte) p);
71
                }
72
                
73
        }
74
        
75
        /*
76
         *  (non-Javadoc)
77
         * @see org.gvsig.fmap.grid.filter.IRasterFilter#getInRasterDataType()
78
         */
79
        public int getInRasterDataType() {
80
                return RasterBuffer.TYPE_BYTE;
81
        }
82

    
83
        /*
84
         *  (non-Javadoc)
85
         * @see org.gvsig.fmap.grid.filter.IRasterFilter#getOutRasterDataType()
86
         */
87
        public int getOutRasterDataType() {
88
                return RasterBuffer.TYPE_BYTE;
89
        }
90

    
91
        /*
92
         *  (non-Javadoc)
93
         * @see org.gvsig.fmap.grid.filter.IRasterFilter#getResult(java.lang.String)
94
         */
95
        public Object getResult(String name) {
96
                if (name.equals("raster")) {
97
            return (Object) this.raster;
98
        } else {
99
            return null;
100
        }
101
        }
102
}