I am trying to create an Graphics image at run time and write it out
to a file using the JPEG encoding provided with JDK1.2. The image
consists
of mostly text, lines and barcode images.
The lines come out fine, but the text is blurred. I am including some of
the
code. Any help would be appreciated.
Also noticed the following:
1. When antialiasing is off, the text font is of very poor quality.
2. When antialiasing is on, the text font seems okay (except for the
blurr
but the characters are stretched out.
thanks
mathew
//Create a buffered image
BufferedImage bi = new
BufferedImage(w,h,BufferedImage.TYPE_INT_RGB) ;
//set up Graphics object
Graphics2D g2 = (Graphics2D)bi.getGraphics();
g2.setBackground(Color.white);
g2.setColor(Color.black);
g2.clearRect(0, 0, w, h);
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
//draw Text and lines
g2.drawString( .....);
....
g2.dispose();
//Encode image using JPEG encoding and store to file
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(bi);
param.setQuality(1.0f, false);
encoder.setJPEGEncodeParam(param);
encoder.encode(bi);
=====================================================================
To subscribe/unsubscribe, send mail to [EMAIL PROTECTED]
Java 2D Home Page: http://java.sun.com/products/java-media/2D/