xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Johan Stuyts" <j.stu...@javathinker.com>
Subject Re: Rendering precision
Date Thu, 04 Feb 2010 21:39:19 GMT
Hi Jan,

I had the same problem and couldn't find any quality settings. I did find  
a protected method of transcoders: createRenderer(), which returns an  
ImageRenderer. You can set Java2D rendering hints on this class. By  
creating a simple subclass you can tell the ImageRenderer to use the  
highest possible quality:


PNGTranscoder t = new PNGTranscoder()
{
     @Override
     protected ImageRenderer createRenderer()
     {
         ImageRenderer r = super.createRenderer();

         RenderingHints rh = r.getRenderingHints();

         rh.add(new RenderingHints(RenderingHints.KEY_ALPHA_INTERPOLATION,
             RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY));
         rh.add(new RenderingHints(RenderingHints.KEY_INTERPOLATION,
             RenderingHints.VALUE_INTERPOLATION_BICUBIC));

         rh.add(new RenderingHints(RenderingHints.KEY_ANTIALIASING,
             RenderingHints.VALUE_ANTIALIAS_ON));

         rh.add(new RenderingHints(RenderingHints.KEY_COLOR_RENDERING,
             RenderingHints.VALUE_COLOR_RENDER_QUALITY));
         rh.add(new RenderingHints(RenderingHints.KEY_DITHERING,
             RenderingHints.VALUE_DITHER_DISABLE));

         rh.add(new RenderingHints(RenderingHints.KEY_RENDERING,
             RenderingHints.VALUE_RENDER_QUALITY));

         rh.add(new RenderingHints(RenderingHints.KEY_STROKE_CONTROL,
             RenderingHints.VALUE_STROKE_PURE));

         rh.add(new RenderingHints(RenderingHints.KEY_FRACTIONALMETRICS,
             RenderingHints.VALUE_FRACTIONALMETRICS_ON));
         rh.add(new RenderingHints(RenderingHints.KEY_TEXT_ANTIALIASING,
             RenderingHints.VALUE_TEXT_ANTIALIAS_OFF));

         r.setRenderingHints(rh);

         return r;
     }
};


Regards,

Johan


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org


Mime
View raw message