Class ImageUtil

java.lang.Object
org.mbari.jcommons.awt.ImageUtil

public class ImageUtil extends Object
  • Method Details

    • addWatermark

      public static BufferedImage addWatermark(BufferedImage bufferedImage, String watermark, Color color, Font font, float alpha)
      Adds text as a watermark to an image as 50% transparent of the supplied color.
      Parameters:
      bufferedImage - The image to add the watermark to
      watermark - The text to add as a watermark
      color - The color of the watermarked text [default = white]
      font - The font to use for the watermark [default = Arial Bold 30pt.]
      alpha -
      Returns:
      The bufferedImage that was passed in (of course it now has the watermark). This was added to allow method chaining.
    • hasAlpha

      public static boolean hasAlpha(Image image)
      This method returns true if the specified image has transparent pixels. This code is from The Java Developers Almanac 1.4
      Parameters:
      image -
      Returns:
    • saveImage

      public static void saveImage(RenderedImage image, File target) throws IOException
      Saves the image to the target file. The format of the saved file is determined by it's extension
      Parameters:
      image - The image to save
      target - The file to save the image to.
      Throws:
      IOException
    • toBufferedImage

      public static BufferedImage toBufferedImage(RenderedImage image)
      Converts a RenderedImage into a BufferedImage. If the RenderedImage is already a BufferedImage then the input argument is returned (i.e. no operations are performed on the image). Found this at http://www.mambo.net/cgi-bin/TempProcessor/view/77
      Parameters:
      image - The RenderedImage to convert
      Returns:
      The input converted to a BufferedImage
    • toBufferedImage

      public static BufferedImage toBufferedImage(Image image)
      This method returns a buffered image with the contents of an image. This code is from The Java Developers Almanac 1.4
      Parameters:
      image - The Image to convert to a BufferedImage
      Returns:
    • toImage

      public static Image toImage(BufferedImage bufferedImage)
      This method returns an Image object from a buffered image. This code is from The Java Developers Almanac 1.4
      Parameters:
      bufferedImage -
      Returns: