Package com.vladsch.flexmark.util.misc
Class ImageUtils
java.lang.Object
com.vladsch.flexmark.util.misc.ImageUtils
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic BufferedImage
addBorder
(BufferedImage image, Color borderColor, int borderWidth, int cornerRadius) static BufferedImage
base64Decode
(File file) static BufferedImage
base64Decode
(String encoded) static String
base64Encode
(BufferedImage image) static String
base64Encode
(File file) static BufferedImage
cropImage
(BufferedImage image, int trimLeft, int trimRight, int trimTop, int trimBottom) static BufferedImage
drawHighlightOval
(BufferedImage image, int x, int y, int w, int h, Color borderColor, int borderWidth, Color innerFillColor) static BufferedImage
drawHighlightRectangle
(BufferedImage image, int x, int y, int w, int h, Color borderColor, int borderWidth, int cornerRadius, Color innerFillColor) static BufferedImage
drawOval
(BufferedImage image, int x, int y, int w, int h, Color borderColor, int borderWidth, float[] dash, float dashPhase) static BufferedImage
drawRectangle
(BufferedImage image, int x, int y, int w, int h, Color borderColor, int borderWidth, int cornerRadius) static BufferedImage
drawRectangle
(BufferedImage image, int x, int y, int w, int h, Color borderColor, int borderWidth, int cornerRadius, float[] dash, float dashPhase) static byte[]
getImageBytes
(BufferedImage image) static Image
static Image
getImageFromTransferable
(Transferable transferable) static boolean
isEncodedImage
(String encoded) static boolean
isPossiblyEncodedImage
(String encoded) static BufferedImage
loadImageFromContent
(byte[] cachedImageBytes, String idPath) static BufferedImage
loadImageFromFile
(File cachedImageFile) static BufferedImage
loadImageFromURL
(String imageURL) static BufferedImage
loadImageFromURL
(String imageURL, boolean logImageProcessing) Load image from URL.static BufferedImage
makeRoundedCorner
(BufferedImage image, int cornerRadius, int borderWidth) static BufferedImage
punchOuterHighlightOval
(BufferedImage image, BufferedImage outerImage, int x, int y, int w, int h, int borderWidth, Color outerFillColor, int outerBorderWidth, int outerCornerRadius, boolean applyToImage) static BufferedImage
punchOuterHighlightRectangle
(BufferedImage image, BufferedImage outerImage, int x, int y, int w, int h, int borderWidth, int cornerRadius, Color outerFillColor, int outerBorderWidth, int outerCornerRadius, boolean applyToImage) static BufferedImage
removeAlpha
(BufferedImage image) static void
save
(BufferedImage image, File file, String format) static BufferedImage
scaleImage
(BufferedImage sourceImage, int newWidth, int newHeight, int opType) static BufferedImage
toBufferedImage
(Image src) static Image
toTransparent
(BufferedImage image, Color color, int tolerance)
-
Field Details
-
TRANSPARENT
-
BASE64_ENCODING_PATTERN
-
-
Constructor Details
-
ImageUtils
public ImageUtils()
-
-
Method Details
-
getImageFromClipboard
-
getImageFromTransferable
-
scaleImage
public static BufferedImage scaleImage(BufferedImage sourceImage, int newWidth, int newHeight, int opType) -
toBufferedImage
-
save
-
loadImageFromFile
- Parameters:
cachedImageFile
- file- Returns:
- Could be
null
if the image could not be read from the file (because of whatever strange reason).
-
loadImageFromContent
- Parameters:
cachedImageBytes
- fileidPath
- image file path for error reporting- Returns:
- Could be
null
if the image could not be read from the file (because of whatever strange reason).
-
base64Encode
-
base64Encode
-
base64Decode
-
isEncodedImage
-
isPossiblyEncodedImage
-
base64Decode
-
loadImageFromURL
-
loadImageFromURL
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 BufferedImage makeRoundedCorner(BufferedImage image, int cornerRadius, int borderWidth) -
addBorder
public static BufferedImage addBorder(BufferedImage image, Color borderColor, int borderWidth, int cornerRadius) -
drawRectangle
public static BufferedImage drawRectangle(BufferedImage image, int x, int y, int w, int h, Color borderColor, int borderWidth, int cornerRadius) -
drawRectangle
public static BufferedImage drawRectangle(BufferedImage image, int x, int y, int w, int h, Color borderColor, int borderWidth, int cornerRadius, float[] dash, float dashPhase) -
drawOval
public static BufferedImage drawOval(BufferedImage image, int x, int y, int w, int h, Color borderColor, int borderWidth, float[] dash, float dashPhase) -
drawHighlightRectangle
public static BufferedImage drawHighlightRectangle(BufferedImage image, int x, int y, int w, int h, Color borderColor, int borderWidth, int cornerRadius, Color innerFillColor) -
drawHighlightOval
public static BufferedImage drawHighlightOval(BufferedImage image, int x, int y, int w, int h, Color borderColor, int borderWidth, Color innerFillColor) -
punchOuterHighlightRectangle
public static BufferedImage punchOuterHighlightRectangle(BufferedImage image, BufferedImage outerImage, int x, int y, int w, int h, int borderWidth, int cornerRadius, Color outerFillColor, int outerBorderWidth, int outerCornerRadius, boolean applyToImage) -
punchOuterHighlightOval
public static BufferedImage punchOuterHighlightOval(BufferedImage image, BufferedImage outerImage, int x, int y, int w, int h, int borderWidth, Color outerFillColor, int outerBorderWidth, int outerCornerRadius, boolean applyToImage) -
cropImage
public static BufferedImage cropImage(BufferedImage image, int trimLeft, int trimRight, int trimTop, int trimBottom) -
removeAlpha
-
toTransparent
-
getImageBytes
-