Package com.saperion.util
Class SaImageConverter
java.lang.Object
com.saperion.util.SaImageConverter
Utility class used to convert between various image formats.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
Image formats available for conversion. -
Method Summary
Modifier and TypeMethodDescriptionstatic BufferedImage
bmpToBufferedImage
(byte[] bmp, SaImageConverter.ImageFormat format) Converts a bitmap to a BufferedImage.static BufferedImage
dibToBufferedImage
(byte[] dibBytes, SaImageConverter.ImageFormat format) Converts a device independent bitmat (DIB) to a BufferedImage.static BufferedImage
makeTransparent
(BufferedImage image, Color color) Makes the given image transparent.
-
Method Details
-
bmpToBufferedImage
public static BufferedImage bmpToBufferedImage(byte[] bmp, SaImageConverter.ImageFormat format) throws IOException, SaImageConverterException Converts a bitmap to a BufferedImage.- Parameters:
bmp
- bitmapformat
- format for the BufferedImage- Returns:
- BufferedImage with the bitmap's content and the specified format
- Throws:
IOException
- io exceptionSaImageConverterException
- image conversion failed
-
dibToBufferedImage
public static BufferedImage dibToBufferedImage(byte[] dibBytes, SaImageConverter.ImageFormat format) throws IOException, SaImageConverterException Converts a device independent bitmat (DIB) to a BufferedImage.- Parameters:
dibBytes
- dib bytesformat
- 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:
IOException
- io exceptionSaImageConverterException
- conversion failed
-
makeTransparent
Makes the given image transparent. Turn all pixels to transparent, which have the given color. UsesRGBImageFilter
filter to convert pixel to transparent.- Parameters:
image
- the image to turn transparencycolor
- the color to turn pixels transparent- Returns:
- the transparent buffered image
-