Statistics
| Revision:

root / trunk / libraries / libCq_CMS_praster / src / org / cresques / filter / enhancement / BrightnessShortFilter.java @ 8026

History | View | Annotate | Download (1.86 KB)

1
package org.cresques.filter.enhancement;
2

    
3
import java.awt.Image;
4
import java.awt.image.BufferedImage;
5

    
6
import org.cresques.io.data.RasterBuf;
7

    
8

    
9
/**
10
 * 
11
 * @author Miguel Ángel Querol Carratalá <querol_mig@gva.es>
12
 *
13
 */
14
public class BrightnessShortFilter extends BrightnessFilter{
15
        private short[]                 px = new short[4];
16
        
17
        public BrightnessShortFilter(){
18
                super();
19
        }
20
        
21
        public void pre(){
22
                exec = true;
23
                this.raster = (RasterBuf) params.get("raster");
24
                height = raster.getHeight();
25
        width = raster.getWidth();
26
                this.incrBrillo = ((Integer) params.get("incrBrillo")).intValue();
27
                
28
                super.pre();
29
        }
30
        
31
        
32

    
33
        public void process(int col, int line) {
34
                raster.getElemShort(line, col, px);
35
                
36
                for(int i = 0 ; i < 3 ; i++){
37
                        if((px[i] + incrBrillo) > 255)
38
                                px[i] = 255;
39
                        else if((px[i] + incrBrillo) < 0)
40
                                px[i] = 0;
41
                        else
42
                                px[i] += incrBrillo;
43
                }
44
                
45
                raster.setElemShort(line, col, px);
46
        }
47

    
48
         /* (non-Javadoc)
49
     * @see org.cresques.io.raster.IRasterFilter#processSuperSampling(int, int)
50
     */
51
        public void processSuperSampling(int col, int line) {
52
                raster.getElemShort(line, col, px);
53
                
54
                for(int i = 0 ; i < 3 ; i++){
55
                        if((px[i] + incrBrillo) > 255)
56
                                px[i] = 255;
57
                        else if((px[i] + incrBrillo) < 0)
58
                                px[i] = 0;
59
                        else
60
                                px[i] += incrBrillo;
61
                }
62
                
63
        for(int j = col; j < raster.getWidth() && j < (col + stepX[contX + 1]); j++)
64
                        for(int i = line; i < raster.getHeight() && i < (line + stepY[contY + 1]); i++)
65
                                 raster.setElemShort(i, j, px);
66
                        
67
        }
68
        
69
        public void processLine(int y) {
70
                // TODO Auto-generated method stub
71
                
72
        }
73

    
74
        public int getInRasterDataType() {
75
                return RasterBuf.TYPE_SHORT;
76
        }
77

    
78
        public int getOutRasterDataType() {
79
                return RasterBuf.TYPE_SHORT;
80
        }
81

    
82
        public Object getResult(String name) {
83
                if (name.equals("raster")) {
84
            return (Object) this.raster;
85
        } else {
86
            return null;
87
        }
88
        }
89
        
90
}