1 17 18 19 20 package org.apache.fop.render.pcl; 21 22 import java.awt.RenderingHints ; 23 import java.awt.color.ColorSpace ; 24 import java.awt.image.BufferedImage ; 25 import java.awt.image.ColorConvertOp ; 26 import java.awt.image.RenderedImage ; 27 28 32 public class DefaultMonochromeBitmapConverter implements 33 MonochromeBitmapConverter { 34 35 36 public void setHint(String name, String value) { 37 } 39 40 41 public RenderedImage convertToMonochrome(BufferedImage img) { 42 BufferedImage buf = new BufferedImage (img.getWidth(), img.getHeight(), 43 BufferedImage.TYPE_BYTE_BINARY); 44 RenderingHints hints = new RenderingHints (null); 45 hints.put(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_ENABLE); 47 ColorConvertOp op = new ColorConvertOp ( 48 ColorSpace.getInstance(ColorSpace.CS_GRAY), hints); 49 op.filter(img, buf); 50 return buf; 51 } 52 53 } 54 | Popular Tags |