/Users/lyon/j4p/src/j2d/hpp/GreyHppFilter3.java
|
1 /*
2 * Created by DocJava, Inc.
3 * User: lyon
4 * Date: Feb 28, 2003
5 * Time: 7:42:23 AM
6 */
7 package j2d.hpp;
8
9
10 public class GreyHppFilter3 implements HppFilter3Interface {
11 private float ar = 1;
12 private float ag = 1;
13 private float ab = 1;
14
15 public GreyHppFilter3(float ar, float ag, float ab) {
16 this.ar = ar;
17 this.ag = ag;
18 this.ab = ab;
19 }
20
21 public short getR(int r, int g, int b) {
22 return avg(r, g, b);
23 }
24
25 public short getG(int r, int g, int b) {
26 return avg(r, g, b);
27 }
28
29 public short getB(int r, int g, int b) {
30 return avg(r, g, b);
31 }
32
33 private short avg(int r, int g, int b) {
34 return (short) ((r * ar + g * ag + b * ab) / 3);
35 }
36 }
37