1 18 package org.apache.batik.ext.awt.image.rendered; 19 20 import java.awt.RenderingHints ; 21 import java.awt.image.ByteLookupTable ; 22 import java.awt.image.LookupOp ; 23 import java.awt.image.WritableRaster ; 24 25 import org.apache.batik.ext.awt.image.GraphicsUtil; 26 import org.apache.batik.ext.awt.image.TransferFunction; 27 28 33 public class ComponentTransferRed extends AbstractRed { 34 LookupOp operation; 35 36 45 public ComponentTransferRed(CachableRed src, 46 TransferFunction [] funcs, 47 RenderingHints hints) { 48 super(src, src.getBounds(), 49 GraphicsUtil.coerceColorModel(src.getColorModel(), false), 50 src.getSampleModel(), 51 null); 52 53 byte [][] tableData = {funcs[1].getLookupTable(), 54 funcs[2].getLookupTable(), 55 funcs[3].getLookupTable(), 56 funcs[0].getLookupTable()}; 57 58 operation = new LookupOp (new ByteLookupTable (0, tableData), hints) 65 { }; 66 } 67 68 public WritableRaster copyData(WritableRaster wr){ 69 CachableRed src = (CachableRed)getSources().elementAt(0); 70 71 wr = src.copyData(wr); 72 GraphicsUtil.coerceData(wr, src.getColorModel(), false); 73 74 WritableRaster srcWR = wr.createWritableTranslatedChild(0,0); 75 76 operation.filter(srcWR, srcWR); 77 78 return wr; 79 } 80 } 81 | Popular Tags |