Statistics
| Revision:

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

History | View | Annotate | Download (2.73 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 short 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 BrightnessShortFilter extends BrightnessFilter{
33
        private short[]                 px = new short[4];
34
        
35
        /**
36
         * Constructor. Llama al constructor de la clase
37
         * padre.
38
         */
39
        public BrightnessShortFilter(){
40
                super();
41
        }
42
        
43
        /*
44
         *  (non-Javadoc)
45
         * @see org.gvsig.fmap.grid.filter.IRasterFilter#pre()
46
         */
47
        public void pre(){
48
                exec = true;
49
                this.raster = (RasterBuffer) params.get("raster");
50
                height = raster.getHeight();
51
        width = raster.getWidth();
52
                this.incrBrillo = ((Integer) params.get("incrBrillo")).intValue();
53
                
54
                super.pre();
55
        }
56
        
57
        /*
58
         *  (non-Javadoc)
59
         * @see org.gvsig.fmap.grid.filter.IRasterFilter#process(int, int)
60
         */
61
        public void process(int col, int line) {
62
                raster.getElemShort(line, col, px);
63

    
64
                for (int i = 0; i < 3; i++) {
65
                        px[i] = (short) (px[i] % 256);
66

    
67
                        px[i] = (short) (px[i] + incrBrillo);
68
                        if (px[i] > 255)
69
                                px[i] = 255;
70
                        else if (px[i] < 0)
71
                                px[i] = 0;
72
                }
73

    
74
                raster.setElemShort(line, col, px);
75
        }
76
        
77
        /*
78
         *  (non-Javadoc)
79
         * @see org.gvsig.fmap.grid.filter.IRasterFilter#getInRasterDataType()
80
         */
81
        public int getInRasterDataType() {
82
                return RasterBuffer.TYPE_SHORT;
83
        }
84

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

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