/Users/lyon/j4p/src/j2d/hpp/ContrastFilter.java

1    /* 
2     * Created by DocJava, Inc. 
3     * User: lyon 
4     * Date: Feb 28, 2003 
5     * Time: 7:44:33 AM 
6     */ 
7    package j2d.hpp; 
8     
9     
10   public class ContrastFilter implements HppFilterInterface { 
11       private double c, b; 
12    
13       public ContrastFilter(double _c, double _b) { 
14           c = _c; 
15           b = _b; 
16    
17       } 
18    
19       public short getR(int r) { 
20           return contrast(r); 
21       } 
22    
23       public short getG(int g) { 
24           return contrast(g); 
25       } 
26    
27       public short getB(int b) { 
28           return contrast(b); 
29       } 
30    
31       private short contrast(double v) { 
32           v = c * v + b; 
33           if (v < 0) return 0; 
34           if (v > 255) return 255; 
35           return (short) (v); 
36       } 
37    
38   } 
39