1 18 package org.apache.batik.svggen; 19 20 import java.awt.image.BufferedImage ; 21 import java.io.IOException ; 22 import java.io.OutputStream ; 23 24 import org.apache.batik.ext.awt.image.codec.ImageEncoder; 25 import org.apache.batik.ext.awt.image.codec.PNGImageEncoder; 26 27 33 public class CachedImageHandlerPNGEncoder extends DefaultCachedImageHandler { 34 public static final String CACHED_PNG_PREFIX = "pngImage"; 35 public static final String CACHED_PNG_SUFFIX = ".png"; 36 37 protected String refPrefix = ""; 38 39 46 public CachedImageHandlerPNGEncoder(String imageDir, String urlRoot) 47 throws SVGGraphics2DIOException { 48 refPrefix = urlRoot + "/"; 49 setImageCacher(new ImageCacher.External(imageDir, 50 CACHED_PNG_PREFIX, 51 CACHED_PNG_SUFFIX)); 52 } 53 54 55 58 public void encodeImage(BufferedImage buf, OutputStream os) 59 throws IOException { 60 ImageEncoder encoder = new PNGImageEncoder(os, null); 61 encoder.encode(buf); 62 } 63 64 public int getBufferedImageType(){ 65 return BufferedImage.TYPE_INT_ARGB; 66 } 67 68 public String getRefPrefix(){ 69 return refPrefix; 70 } 71 } 72 | Popular Tags |