Package mil.nga.geopackage.tiles
Class ImageUtils
- java.lang.Object
-
- mil.nga.geopackage.tiles.ImageUtils
-
public class ImageUtils extends Object
Image utility methods- Author:
- osbornb
-
-
Field Summary
Fields Modifier and Type Field Description static String
IMAGE_FORMAT_JPEG
jpeg image formatstatic String
IMAGE_FORMAT_JPG
jpg image formatstatic String
IMAGE_FORMAT_PNG
png image formatstatic String
IMAGE_FORMAT_TIFF
tiff image format
-
Constructor Summary
Constructors Constructor Description ImageUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
closeQuietly(Closeable closeable)
Close quietlystatic byte[]
compressAndWriteImageToBytes(BufferedImage image, String formatName, float quality)
Compress and write the image to bytes in the provided format and qualitystatic BufferedImage
createBufferedImage(int width, int height, String imageFormat)
Create a buffered image for the dimensions and image formatstatic BufferedImage
getImage(byte[] imageBytes)
Get a buffered image of the image bytesstatic boolean
isFullyTransparent(BufferedImage image)
Check if the image is fully transparent, meaning it contains only transparent pixels as an empty imagestatic boolean
isTransparent(BufferedImage image, int x, int y)
Check if the pixel in the image at the x and y is transparentstatic byte[]
writeImageToBytes(BufferedImage image, String formatName)
Write the image to bytes in the provided formatstatic byte[]
writeImageToBytes(BufferedImage image, String formatName, Float quality)
Write the image to bytes in the provided format and optional quality
-
-
-
Field Detail
-
IMAGE_FORMAT_PNG
public static final String IMAGE_FORMAT_PNG
png image format- See Also:
- Constant Field Values
-
IMAGE_FORMAT_JPG
public static final String IMAGE_FORMAT_JPG
jpg image format- See Also:
- Constant Field Values
-
IMAGE_FORMAT_JPEG
public static final String IMAGE_FORMAT_JPEG
jpeg image format- See Also:
- Constant Field Values
-
IMAGE_FORMAT_TIFF
public static final String IMAGE_FORMAT_TIFF
tiff image format- Since:
- 1.2.1
- See Also:
- Constant Field Values
-
-
Method Detail
-
createBufferedImage
public static BufferedImage createBufferedImage(int width, int height, String imageFormat)
Create a buffered image for the dimensions and image format- Parameters:
width
- image widthheight
- image heightimageFormat
- image format- Returns:
- image
-
isFullyTransparent
public static boolean isFullyTransparent(BufferedImage image)
Check if the image is fully transparent, meaning it contains only transparent pixels as an empty image- Parameters:
image
- image- Returns:
- true if fully transparent
-
isTransparent
public static boolean isTransparent(BufferedImage image, int x, int y)
Check if the pixel in the image at the x and y is transparent- Parameters:
image
- imagex
- x locationy
- y location- Returns:
- true if transparent
-
getImage
public static BufferedImage getImage(byte[] imageBytes) throws IOException
Get a buffered image of the image bytes- Parameters:
imageBytes
- image bytes- Returns:
- buffered image or null
- Throws:
IOException
- upon failure- Since:
- 1.1.2
-
writeImageToBytes
public static byte[] writeImageToBytes(BufferedImage image, String formatName, Float quality) throws IOException
Write the image to bytes in the provided format and optional quality- Parameters:
image
- buffered imageformatName
- image format namequality
- null or quality between 0.0 and 1.0- Returns:
- image bytes
- Throws:
IOException
- upon failure- Since:
- 1.1.2
-
writeImageToBytes
public static byte[] writeImageToBytes(BufferedImage image, String formatName) throws IOException
Write the image to bytes in the provided format- Parameters:
image
- buffered imageformatName
- image format name- Returns:
- image bytes
- Throws:
IOException
- upon failure- Since:
- 1.1.2
-
compressAndWriteImageToBytes
public static byte[] compressAndWriteImageToBytes(BufferedImage image, String formatName, float quality)
Compress and write the image to bytes in the provided format and quality- Parameters:
image
- buffered imageformatName
- image format namequality
- quality between 0.0 and 1.0- Returns:
- compressed image bytes
- Since:
- 1.1.2
-
closeQuietly
public static void closeQuietly(Closeable closeable)
Close quietly- Parameters:
closeable
- closeable- Since:
- 1.1.2
-
-