Class ImageUtils

java.lang.Object
com.vladsch.flexmark.util.misc.ImageUtils

public class ImageUtils extends Object
  • Field Details

    • TRANSPARENT

      public static Color TRANSPARENT
    • BASE64_ENCODING_PATTERN

      private static final Pattern BASE64_ENCODING_PATTERN
  • Constructor Details

    • ImageUtils

      public ImageUtils()
  • Method Details

    • 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 null if 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 - file
      idPath - 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

      public static String base64Encode(BufferedImage image)
    • base64Encode

      public static String base64Encode(File file)
    • 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 image
      logImageProcessing - 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)