Java ByteBuffer Size makeOval(BufferedImage input, int width, int height)

Here you can find the source of makeOval(BufferedImage input, int width, int height)

Description

Crop the image to a smooth oval

License

Open Source License

Parameter

Parameter Description
input a parameter
width a parameter
height a parameter

Declaration

public static BufferedImage makeOval(BufferedImage input, int width, int height) 

Method Source Code


//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;
    }
}

Related

  1. findNewHeight(BufferedImage origImage, double newWidth)
  2. FindResolution(BufferedImage img, double print_width, double print_height)
  3. fitToSize(BufferedImage source, int targetWidth, int targetHeight)
  4. generateScaledImage(final BufferedImage bufImg, @SuppressWarnings("unused") final Object hintsArg, final int size)
  5. makeBrighterRectangleOnImage(BufferedImage image, int leftPosition, int topPosition, int width, int height, double scaleFactor, Color borderColor, Stroke borderStroke)
  6. makeTarget(BufferedImage image, int x, int y, int width, int height)
  7. mapByteBuffer(File cachedFile, int cacheFileSize)
  8. markDifferencesWithAMarker(final BufferedImage image, final Point[] pixels, final int markingSizeX, final int markingSizeY)
  9. markDifferencesWithBoxes(final BufferedImage image, final Point[] pixels, final int markingSizeX, final int markingSizeY)