Package com.vladsch.flexmark.util.misc
Class ImageUtils
- java.lang.Object
-
- com.vladsch.flexmark.util.misc.ImageUtils
-
public class ImageUtils extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static ColorTRANSPARENT
-
Constructor Summary
Constructors Constructor Description ImageUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static BufferedImageaddBorder(BufferedImage image, Color borderColor, int borderWidth, int cornerRadius)static BufferedImagebase64Decode(File file)static BufferedImagebase64Decode(String encoded)static Stringbase64Encode(BufferedImage image)static Stringbase64Encode(File file)static BufferedImagecropImage(BufferedImage image, int trimLeft, int trimRight, int trimTop, int trimBottom)static BufferedImagedrawHighlightOval(BufferedImage image, int x, int y, int w, int h, Color borderColor, int borderWidth, Color innerFillColor)static BufferedImagedrawHighlightRectangle(BufferedImage image, int x, int y, int w, int h, Color borderColor, int borderWidth, int cornerRadius, Color innerFillColor)static BufferedImagedrawOval(BufferedImage image, int x, int y, int w, int h, Color borderColor, int borderWidth, float[] dash, float dashPhase)static BufferedImagedrawRectangle(BufferedImage image, int x, int y, int w, int h, Color borderColor, int borderWidth, int cornerRadius)static BufferedImagedrawRectangle(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 ImagegetImageFromClipboard()static ImagegetImageFromTransferable(Transferable transferable)static booleanisEncodedImage(String encoded)static booleanisPossiblyEncodedImage(String encoded)static BufferedImageloadImageFromContent(byte[] cachedImageBytes, String idPath)static BufferedImageloadImageFromFile(File cachedImageFile)static BufferedImageloadImageFromURL(String imageURL)static BufferedImageloadImageFromURL(String imageURL, boolean logImageProcessing)Load image from URL.static BufferedImagemakeRoundedCorner(BufferedImage image, int cornerRadius, int borderWidth)static BufferedImagepunchOuterHighlightOval(BufferedImage image, BufferedImage outerImage, int x, int y, int w, int h, int borderWidth, Color outerFillColor, int outerBorderWidth, int outerCornerRadius, boolean applyToImage)static BufferedImagepunchOuterHighlightRectangle(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 BufferedImageremoveAlpha(BufferedImage image)static voidsave(BufferedImage image, File file, String format)static BufferedImagescaleImage(BufferedImage sourceImage, int newWidth, int newHeight, int opType)static BufferedImagetoBufferedImage(Image src)static ImagetoTransparent(BufferedImage image, Color color, int tolerance)
-
-
-
Field Detail
-
TRANSPARENT
public static Color TRANSPARENT
-
-
Method Detail
-
getImageFromClipboard
public static Image getImageFromClipboard()
-
getImageFromTransferable
public static Image getImageFromTransferable(Transferable transferable)
-
scaleImage
public static BufferedImage scaleImage(BufferedImage sourceImage, int newWidth, int newHeight, int opType)
-
toBufferedImage
public static BufferedImage toBufferedImage(Image src)
-
save
public static void save(BufferedImage image, File file, String format)
-
loadImageFromFile
public static BufferedImage loadImageFromFile(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 BufferedImage loadImageFromContent(byte[] cachedImageBytes, 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 String base64Encode(BufferedImage image)
-
base64Decode
public static BufferedImage base64Decode(File file)
-
isEncodedImage
public static boolean isEncodedImage(String encoded)
-
isPossiblyEncodedImage
public static boolean isPossiblyEncodedImage(String encoded)
-
base64Decode
public static BufferedImage base64Decode(String encoded)
-
loadImageFromURL
public static BufferedImage loadImageFromURL(String imageURL)
-
loadImageFromURL
public static BufferedImage loadImageFromURL(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 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
public static BufferedImage removeAlpha(BufferedImage image)
-
toTransparent
public static Image toTransparent(BufferedImage image, Color color, int tolerance)
-
getImageBytes
public static byte[] getImageBytes(BufferedImage image)
-
-