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

1    package j2d.hpp; 
2     
3     
4    public class HppTransformTable { 
5        private short lutR[] = new short[256]; 
6        private short lutG[] = new short[256]; 
7        private short lutB[] = new short[256]; 
8     
9        public HppTransformTable(HppFilterInterface f) { 
10           for (int i = 0; i < 256; i++) { 
11               lutR[i] = (short) (f.getR(i) & 0XFF); 
12               lutG[i] = (short) (f.getG(i) & 0XFF); 
13               lutB[i] = (short) (f.getB(i) & 0XFF); 
14           } 
15       } 
16    
17    
18       public void applyLut(short r[][], short g[][], short b[][]) { 
19           int w = r.length; 
20           int h = r[0].length; 
21    
22           for (int x = 0; x < w; x++) 
23               for (int y = 0; y < h; y++) { 
24                   r[x][y] = lutR[r[x][y]]; 
25                   g[x][y] = lutG[g[x][y]]; 
26                   b[x][y] = lutB[b[x][y]]; 
27               } 
28       } 
29    
30       public void print() { 
31           for (int i = 0; i < lutR.length; i++) { 
32               System.out.println(i 
33                       + '\t' + lutR[i] 
34                       + '\t' + lutG[i] 
35                       + '\t' + lutB[i]); 
36           } 
37       } 
38   }