1 18 package org.apache.batik.ext.awt.image; 19 20 21 29 public class DiscreteTransfer implements TransferFunction { 30 33 public byte [] lutData; 34 35 38 public int [] tableValues; 39 40 43 private int n; 44 45 49 public DiscreteTransfer(int [] tableValues){ 50 this.tableValues = tableValues; 51 this.n = tableValues.length; 52 } 53 54 58 private void buildLutData(){ 59 lutData = new byte [256]; 60 int i, j; 61 for (j=0; j<=255; j++){ 62 i = (int)(Math.floor(j*n/255f)); 63 if(i == n){ 64 i = n-1; 65 } 66 lutData[j] = (byte)(tableValues[i] & 0xff); 67 } 68 } 69 70 74 public byte [] getLookupTable(){ 75 buildLutData(); 76 return lutData; 77 } 78 } 79 | Popular Tags |