/** * Program to generate a 5"x10" ellipse for Elver portlights. * Compile with JDK 1.3 or above, then display oval.jpg in a * webpage. For my printer one inch = 96 pixels. Your results * may vary. Use the following html code to display the JPeg in * Internet Explorer. * *
*
* (c) Will Marsh 2003
*/
import java.util.*;
import java.awt.*;
import java.io.*;
import java.awt.image.*;
import com.sun.image.codec.jpeg.*;
public class El{
public static void main(String args[]) throws Exception{
BufferedImage bi = new BufferedImage(800,1000,BufferedImage.TYPE_INT_RGB);
Graphics2D g2d = bi.createGraphics();
g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION,RenderingHints.VALUE_INTERPOLATION_BILINEAR);
g2d.setColor(Color.white);
g2d.fillRect(0,0,800,1000);
g2d.setColor(Color.blue);
g2d.drawOval(0,0,480,960);
g2d.drawLine(0,480,500,480);
FileOutputStream fos = new FileOutputStream("oval.jpg");
BufferedOutputStream bos = new BufferedOutputStream(fos);
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(bos);
JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(bi);
param.setQuality((float)0.5,true);
encoder.setJPEGEncodeParam(param);
encoder.encode(bi);
bos.close();
fos.close();
}
}