Package org.carrot2.util
Class BufferedImageUtils
java.lang.Object
org.carrot2.util.BufferedImageUtils
Various utility methods for working with
BufferedImages.-
Method Summary
Modifier and TypeMethodDescriptionstatic intcountDistinctColors(BufferedImage image) Returns the number of distinct colors (excluding transparency) in theimage.static voiddrawImage(BufferedImage image, BufferedImage canvas, int x, int y) Drawsimageon thecanvasplacing the top left corner ofimageatx/yoffset from the top left corner ofcanvas.static int[]getDistinctColors(BufferedImage image) Returns theimage's distinct colors in an RGB format, discarding transparency information.static int[]getDistinctColors(BufferedImage image, int padding) Returns theimage's distinct colors in an RGB format, discarding transparency information.static int[][]getRgb(BufferedImage image) Returns a two dimensional array of theimage's RGB values, including transparency.static booleanReturnstrueif the provided image has partially transparent areas (alpha channel).static booleanhasTransparency(BufferedImage image) Returnstrueif the provided image has any kind of transparent areas.static BufferedImagematte(BufferedImage source, Color matteColor) Performs matting of thesourceimage usingmatteColor.
-
Method Details
-
hasPartialTransparency
Returnstrueif the provided image has partially transparent areas (alpha channel).- Parameters:
image- the image- Returns:
- true, if successful
-
hasTransparency
Returnstrueif the provided image has any kind of transparent areas.- Parameters:
image- the image- Returns:
- true, if successful
-
countDistinctColors
Returns the number of distinct colors (excluding transparency) in theimage.- Parameters:
image- the image- Returns:
- the int
-
getDistinctColors
Returns theimage's distinct colors in an RGB format, discarding transparency information.- Parameters:
image- the image- Returns:
- the distinct colors
-
getDistinctColors
Returns theimage's distinct colors in an RGB format, discarding transparency information. Addspaddingempty slots at the beginning of the returned array.- Parameters:
image- the imagepadding- the padding- Returns:
- the distinct colors
-
getRgb
Returns a two dimensional array of theimage's RGB values, including transparency.- Parameters:
image- the image- Returns:
- the rgb
-
matte
Performs matting of thesourceimage usingmatteColor. Matting is rendering partial transparencies using solid color as if the original image was put on top of a bitmap filled withmatteColor.- Parameters:
source- the sourcematteColor- the matte color- Returns:
- the buffered image
-
drawImage
Drawsimageon thecanvasplacing the top left corner ofimageatx/yoffset from the top left corner ofcanvas.- Parameters:
image- the imagecanvas- the canvasx- the xy- the y
-