1 18 package org.apache.batik.ext.awt.image; 19 20 30 public class LinearTransfer implements TransferFunction { 31 34 public byte [] lutData; 35 36 39 public float slope; 40 41 44 public float intercept; 45 46 49 public LinearTransfer(float slope, float intercept){ 50 this.slope = slope; 51 this.intercept = intercept; 52 } 53 54 58 private void buildLutData(){ 59 lutData = new byte [256]; 60 int j, value; 61 float scaledInt = (intercept*255f)+0.5f; 62 for (j=0; j<=255; j++){ 63 value = (int)(slope*j+scaledInt); 64 if(value < 0){ 65 value = 0; 66 } 67 else if(value > 255){ 68 value = 255; 69 } 70 lutData[j] = (byte)(0xff & value); 71 } 72 73 79 } 80 81 85 public byte [] getLookupTable(){ 86 buildLutData(); 87 return lutData; 88 } 89 } 90 | Popular Tags |