java.lang.Object
org.mbari.jcommons.awt.ImageUtil
-
Method Summary
Modifier and TypeMethodDescriptionstatic BufferedImageaddWatermark(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.static booleanThis method returns true if the specified image has transparent pixels.static voidsaveImage(RenderedImage image, File target) Saves the image to the target file.static BufferedImagetoBufferedImage(Image image) This method returns a buffered image with the contents of an image.static BufferedImagetoBufferedImage(RenderedImage image) Converts a RenderedImage into a BufferedImage.static ImagetoImage(BufferedImage bufferedImage) This method returns an Image object from a buffered image.
-
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 towatermark- The text to add as a watermarkcolor- 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
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
Saves the image to the target file. The format of the saved file is determined by it's extension- Parameters:
image- The image to savetarget- The file to save the image to.- Throws:
IOException
-
toBufferedImage
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
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
This method returns an Image object from a buffered image. This code is from The Java Developers Almanac 1.4- Parameters:
bufferedImage-- Returns:
-