Here you can find the source of makeOval(BufferedImage input, int width, int height)
Parameter | Description |
---|---|
input | a parameter |
width | a parameter |
height | a parameter |
public static BufferedImage makeOval(BufferedImage input, int width, int height)
//package com.java2s; //License from project: Open Source License import java.awt.AlphaComposite; import java.awt.Color; import java.awt.Graphics2D; import java.awt.RenderingHints; import java.awt.geom.Ellipse2D; import java.awt.image.BufferedImage; public class Main { /** Crop the image to a smooth oval * /*www. ja va 2s . co m*/ * @param input * @param width * @param height * @return */ public static BufferedImage makeOval(BufferedImage input, int width, int height) { BufferedImage output = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); Graphics2D g = output.createGraphics(); g.setComposite(AlphaComposite.Src); g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.setColor(Color.WHITE); g.fill(new Ellipse2D.Float(0, 0, width, height)); g.setComposite(AlphaComposite.SrcAtop); g.drawImage(input, 0, 0, null); g.dispose(); return output; } }