/Users/lyon/j4p/src/j2d/hpp/InvertFilter.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 import j2d.ImageProcessorInterface;
10
11 import java.awt.*;
12
13
14 public class InvertFilter
15 implements HppFilterInterface {
16 public short getR(int r) {
17 return invert(r);
18 }
19
20 public short getG(int g) {
21 return invert(g);
22 }
23
24 public short getB(int b) {
25 return invert(b);
26 }
27
28 private short invert(int v) {
29 if (v < 0) return 0;
30 if (v > 255) return 255;
31 return (short) (255 - v);
32 }
33
34 public static ImageProcessorInterface getProcessor() {
35 return new HppFilterImageProcessor(
36 new InvertFilter());
37 }
38
39 }
40