Class SaImageConverter


  • public final class SaImageConverter
    extends java.lang.Object
    Utility class used to convert between various image formats.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  SaImageConverter.ImageFormat
      Image formats available for conversion.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.awt.image.BufferedImage bmpToBufferedImage​(byte[] bmp, SaImageConverter.ImageFormat format)
      Converts a bitmap to a BufferedImage.
      static java.awt.image.BufferedImage dibToBufferedImage​(byte[] dibBytes, SaImageConverter.ImageFormat format)
      Converts a device independent bitmat (DIB) to a BufferedImage.
      static java.awt.image.BufferedImage makeTransparent​(java.awt.image.BufferedImage image, java.awt.Color color)
      Makes the given image transparent.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • bmpToBufferedImage

        public static java.awt.image.BufferedImage bmpToBufferedImage​(byte[] bmp,
                                                                      SaImageConverter.ImageFormat format)
                                                               throws java.io.IOException,
                                                                      SaImageConverterException
        Converts a bitmap to a BufferedImage.
        Parameters:
        bmp - bitmap
        format - format for the BufferedImage
        Returns:
        BufferedImage with the bitmap's content and the specified format
        Throws:
        java.io.IOException - io exception
        SaImageConverterException - image conversion failed
      • dibToBufferedImage

        public static java.awt.image.BufferedImage dibToBufferedImage​(byte[] dibBytes,
                                                                      SaImageConverter.ImageFormat format)
                                                               throws java.io.IOException,
                                                                      SaImageConverterException
        Converts a device independent bitmat (DIB) to a BufferedImage.
        Parameters:
        dibBytes - dib bytes
        format - format for the BufferedImage
        Returns:
        BufferedImage with the dib's content and the specified format or null if the dib bytes contained only zeros
        Throws:
        java.io.IOException - io exception
        SaImageConverterException - conversion failed
      • makeTransparent

        public static java.awt.image.BufferedImage makeTransparent​(java.awt.image.BufferedImage image,
                                                                   java.awt.Color color)
        Makes the given image transparent. Turn all pixels to transparent, which have the given color. Uses RGBImageFilter filter to convert pixel to transparent.
        Parameters:
        image - the image to turn transparency
        color - the color to turn pixels transparent
        Returns:
        the transparent buffered image