1 18 package org.apache.batik.ext.awt.image; 19 20 21 31 public class GammaTransfer implements TransferFunction { 32 35 public byte [] lutData; 36 37 40 public float amplitude; 41 42 45 public float exponent; 46 47 50 public float offset; 51 52 55 public GammaTransfer(float amplitude, float exponent, float offset){ 56 this.amplitude = amplitude; 57 this.exponent = exponent; 58 this.offset = offset; 59 } 60 61 65 private void buildLutData(){ 66 lutData = new byte [256]; 67 int j, v; 68 for (j=0; j<=255; j++){ 69 v = (int)Math.round(255*(amplitude*Math.pow(j/255f, exponent)+offset)); 70 if(v > 255){ 71 v = (byte)0xff; 72 } 73 else if(v < 0){ 74 v = (byte)0x00; 75 } 76 lutData[j] = (byte)(v & 0xff); 77 } 78 } 79 80 81 85 public byte [] getLookupTable(){ 86 buildLutData(); 87 return lutData; 88 } 89 } 90 | Popular Tags |