Package com.vladsch.flexmark.util.misc
Class ImageUtils
- java.lang.Object
-
- com.vladsch.flexmark.util.misc.ImageUtils
-
public class ImageUtils extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description private static java.util.regex.PatternBASE64_ENCODING_PATTERNstatic java.awt.ColorTRANSPARENT
-
Constructor Summary
Constructors Constructor Description ImageUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.awt.image.BufferedImageaddBorder(java.awt.image.BufferedImage image, java.awt.Color borderColor, int borderWidth, int cornerRadius)static java.awt.image.BufferedImagebase64Decode(java.io.File file)static java.awt.image.BufferedImagebase64Decode(java.lang.String encoded)static java.lang.Stringbase64Encode(java.awt.image.BufferedImage image)static java.lang.Stringbase64Encode(java.io.File file)static java.awt.image.BufferedImagecropImage(java.awt.image.BufferedImage image, int trimLeft, int trimRight, int trimTop, int trimBottom)static java.awt.image.BufferedImagedrawHighlightOval(java.awt.image.BufferedImage image, int x, int y, int w, int h, java.awt.Color borderColor, int borderWidth, java.awt.Color innerFillColor)static java.awt.image.BufferedImagedrawHighlightRectangle(java.awt.image.BufferedImage image, int x, int y, int w, int h, java.awt.Color borderColor, int borderWidth, int cornerRadius, java.awt.Color innerFillColor)static java.awt.image.BufferedImagedrawOval(java.awt.image.BufferedImage image, int x, int y, int w, int h, java.awt.Color borderColor, int borderWidth, float[] dash, float dashPhase)static java.awt.image.BufferedImagedrawRectangle(java.awt.image.BufferedImage image, int x, int y, int w, int h, java.awt.Color borderColor, int borderWidth, int cornerRadius)static java.awt.image.BufferedImagedrawRectangle(java.awt.image.BufferedImage image, int x, int y, int w, int h, java.awt.Color borderColor, int borderWidth, int cornerRadius, float[] dash, float dashPhase)static byte[]getImageBytes(java.awt.image.BufferedImage image)static java.awt.ImagegetImageFromClipboard()static java.awt.ImagegetImageFromTransferable(java.awt.datatransfer.Transferable transferable)static booleanisEncodedImage(java.lang.String encoded)static booleanisPossiblyEncodedImage(java.lang.String encoded)static java.awt.image.BufferedImageloadImageFromContent(byte[] cachedImageBytes, java.lang.String idPath)static java.awt.image.BufferedImageloadImageFromFile(java.io.File cachedImageFile)static java.awt.image.BufferedImageloadImageFromURL(java.lang.String imageURL)static java.awt.image.BufferedImageloadImageFromURL(java.lang.String imageURL, boolean logImageProcessing)Load image from URL.static java.awt.image.BufferedImagemakeRoundedCorner(java.awt.image.BufferedImage image, int cornerRadius, int borderWidth)static java.awt.image.BufferedImagepunchOuterHighlightOval(java.awt.image.BufferedImage image, java.awt.image.BufferedImage outerImage, int x, int y, int w, int h, int borderWidth, java.awt.Color outerFillColor, int outerBorderWidth, int outerCornerRadius, boolean applyToImage)static java.awt.image.BufferedImagepunchOuterHighlightRectangle(java.awt.image.BufferedImage image, java.awt.image.BufferedImage outerImage, int x, int y, int w, int h, int borderWidth, int cornerRadius, java.awt.Color outerFillColor, int outerBorderWidth, int outerCornerRadius, boolean applyToImage)static java.awt.image.BufferedImageremoveAlpha(java.awt.image.BufferedImage image)static voidsave(java.awt.image.BufferedImage image, java.io.File file, java.lang.String format)static java.awt.image.BufferedImagescaleImage(java.awt.image.BufferedImage sourceImage, int newWidth, int newHeight, int opType)static java.awt.image.BufferedImagetoBufferedImage(java.awt.Image src)static java.awt.ImagetoTransparent(java.awt.image.BufferedImage image, java.awt.Color color, int tolerance)
-
-
-
Method Detail
-
getImageFromClipboard
public static java.awt.Image getImageFromClipboard()
-
getImageFromTransferable
public static java.awt.Image getImageFromTransferable(java.awt.datatransfer.Transferable transferable)
-
scaleImage
public static java.awt.image.BufferedImage scaleImage(java.awt.image.BufferedImage sourceImage, int newWidth, int newHeight, int opType)
-
toBufferedImage
public static java.awt.image.BufferedImage toBufferedImage(java.awt.Image src)
-
save
public static void save(java.awt.image.BufferedImage image, java.io.File file, java.lang.String format)
-
loadImageFromFile
public static java.awt.image.BufferedImage loadImageFromFile(java.io.File cachedImageFile)
- Parameters:
cachedImageFile- file- Returns:
- Could be
nullif the image could not be read from the file (because of whatever strange reason).
-
loadImageFromContent
public static java.awt.image.BufferedImage loadImageFromContent(byte[] cachedImageBytes, java.lang.String idPath)- Parameters:
cachedImageBytes- fileidPath- image file path for error reporting- Returns:
- Could be
nullif the image could not be read from the file (because of whatever strange reason).
-
base64Encode
public static java.lang.String base64Encode(java.awt.image.BufferedImage image)
-
base64Encode
public static java.lang.String base64Encode(java.io.File file)
-
base64Decode
public static java.awt.image.BufferedImage base64Decode(java.io.File file)
-
isEncodedImage
public static boolean isEncodedImage(java.lang.String encoded)
-
isPossiblyEncodedImage
public static boolean isPossiblyEncodedImage(java.lang.String encoded)
-
base64Decode
public static java.awt.image.BufferedImage base64Decode(java.lang.String encoded)
-
loadImageFromURL
public static java.awt.image.BufferedImage loadImageFromURL(java.lang.String imageURL)
-
loadImageFromURL
public static java.awt.image.BufferedImage loadImageFromURL(java.lang.String imageURL, boolean logImageProcessing)Load image from URL.NOTE: Java7 JDK cannot load some images including GitHub emoji. Compiling this library with Java8 solves the problem.
- Parameters:
imageURL- url of the imagelogImageProcessing- true if errors are to print to console- Returns:
- image or null if failed to download.
-
makeRoundedCorner
public static java.awt.image.BufferedImage makeRoundedCorner(java.awt.image.BufferedImage image, int cornerRadius, int borderWidth)
-
addBorder
public static java.awt.image.BufferedImage addBorder(java.awt.image.BufferedImage image, java.awt.Color borderColor, int borderWidth, int cornerRadius)
-
drawRectangle
public static java.awt.image.BufferedImage drawRectangle(java.awt.image.BufferedImage image, int x, int y, int w, int h, java.awt.Color borderColor, int borderWidth, int cornerRadius)
-
drawRectangle
public static java.awt.image.BufferedImage drawRectangle(java.awt.image.BufferedImage image, int x, int y, int w, int h, java.awt.Color borderColor, int borderWidth, int cornerRadius, float[] dash, float dashPhase)
-
drawOval
public static java.awt.image.BufferedImage drawOval(java.awt.image.BufferedImage image, int x, int y, int w, int h, java.awt.Color borderColor, int borderWidth, float[] dash, float dashPhase)
-
drawHighlightRectangle
public static java.awt.image.BufferedImage drawHighlightRectangle(java.awt.image.BufferedImage image, int x, int y, int w, int h, java.awt.Color borderColor, int borderWidth, int cornerRadius, java.awt.Color innerFillColor)
-
drawHighlightOval
public static java.awt.image.BufferedImage drawHighlightOval(java.awt.image.BufferedImage image, int x, int y, int w, int h, java.awt.Color borderColor, int borderWidth, java.awt.Color innerFillColor)
-
punchOuterHighlightRectangle
public static java.awt.image.BufferedImage punchOuterHighlightRectangle(java.awt.image.BufferedImage image, java.awt.image.BufferedImage outerImage, int x, int y, int w, int h, int borderWidth, int cornerRadius, java.awt.Color outerFillColor, int outerBorderWidth, int outerCornerRadius, boolean applyToImage)
-
punchOuterHighlightOval
public static java.awt.image.BufferedImage punchOuterHighlightOval(java.awt.image.BufferedImage image, java.awt.image.BufferedImage outerImage, int x, int y, int w, int h, int borderWidth, java.awt.Color outerFillColor, int outerBorderWidth, int outerCornerRadius, boolean applyToImage)
-
cropImage
public static java.awt.image.BufferedImage cropImage(java.awt.image.BufferedImage image, int trimLeft, int trimRight, int trimTop, int trimBottom)
-
removeAlpha
public static java.awt.image.BufferedImage removeAlpha(java.awt.image.BufferedImage image)
-
toTransparent
public static java.awt.Image toTransparent(java.awt.image.BufferedImage image, java.awt.Color color, int tolerance)
-
getImageBytes
public static byte[] getImageBytes(java.awt.image.BufferedImage image)
-
-