Class RoundedCorners


  • public class RoundedCorners
    extends java.lang.Object
    Class to round corner of an image.
    Author:
    Christopher Mindus
    • Constructor Summary

      Constructors 
      Constructor Description
      RoundedCorners()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.awt.image.BufferedImage round​(java.awt.image.BufferedImage image, int radiusPercent)
      Performs a "soft-rounded clip" of the image file.
      static void round​(java.io.File input, java.io.File output, java.lang.String formatName, int radiusPercent)
      Performs a "soft-rounded clip" of the image file.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • RoundedCorners

        public RoundedCorners()
    • Method Detail

      • round

        public static void round​(java.io.File input,
                                 java.io.File output,
                                 java.lang.String formatName,
                                 int radiusPercent)
                          throws java.io.IOException
        Performs a "soft-rounded clip" of the image file. The edges might overflow a little bit in the rounded area due to anti-aliasing.
        Parameters:
        input - The input image file.
        output - The output file where the rounded corners are applies.
        formatName - A String containing the informal name of the format.
        radiusPercent - The radius percent to apply to the image file.
        Throws:
        java.io.IOException - For I/O errors.
      • round

        public static java.awt.image.BufferedImage round​(java.awt.image.BufferedImage image,
                                                         int radiusPercent)
        Performs a "soft-rounded clip" of the image file. The edges might overflow a little bit in the rounded area due to anti-aliasing.
        Parameters:
        image - Input image.
        radiusPercent - The rounded corner value in the maximum size of the image, max(width,height).
        Returns:
        The new rounded anti-aliased image.
        Throws:
        java.lang.IllegalArgumentException - If radiusPercent is less than zero or larger than 100.