Package VASSAL.tools.image
Class ImageIOImageLoader
java.lang.Object
VASSAL.tools.image.ImageIOImageLoader
- All Implemented Interfaces:
ImageLoader
An image loader which wraps
ImageIO
.
This class handles the assorted problems with various versions of
ImageIO
, ensuring that we can reliably load image files to
{link BufferedImages} with a predictable type.- Since:
- 3.1.0
- Author:
- Joel Uckelman
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionprotected static final ImageIOImageLoader.Wrapper
<BufferedImage> A functor for reading images.protected static final ImageIOImageLoader.Wrapper
<Dimension> A functor for reading image dimensions.protected final ImageTypeConverter
protected static final boolean
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected BufferedImage
fix_grayscale_gamma
(Reference<BufferedImage> ref, int type) protected BufferedImage
fix_tRNS
(Reference<BufferedImage> ref, int tRNS, int type) protected BufferedImage
fix_YCbCr
(Reference<BufferedImage> ref, int type) load
(String name, InputStream in, int typeIfOpaque, int typeIfTransparent, boolean managed) Loads an image.size
(String name, InputStream in) Gets the size of an image.protected <T> T
wrapImageIO
(String name, InputStream in, ImageIOImageLoader.Wrapper<T> w)
-
Field Details
-
tconv
-
YCbCrBug
protected static final boolean YCbCrBug -
readImage
A functor for reading images. -
readSize
A functor for reading image dimensions.
-
-
Constructor Details
-
ImageIOImageLoader
Create an image loader.- Parameters:
tconv
- theImageTypeConverter
to use for type conversions
-
-
Method Details
-
load
public BufferedImage load(String name, InputStream in, int typeIfOpaque, int typeIfTransparent, boolean managed) throws ImageIOException Loads an image.- Specified by:
load
in interfaceImageLoader
- Parameters:
name
- the image namein
- the input streamtypeIfOpaque
- the requested image type for opaque imagestypeIfTransparent
- the requested image type for transparent imagesmanaged
-true
if a managed image should be returned- Returns:
- the image
- Throws:
BrokenImageException
- if the image is faultyUnrecognizedImageTypeException
- if the image type is not recognizedImageIOException
- if reading the image goes wrong
-
wrapImageIO
protected <T> T wrapImageIO(String name, InputStream in, ImageIOImageLoader.Wrapper<T> w) throws ImageIOException - Throws:
ImageIOException
-
fix_tRNS
protected BufferedImage fix_tRNS(Reference<BufferedImage> ref, int tRNS, int type) throws ImageIOException - Throws:
ImageIOException
-
fix_YCbCr
- Throws:
ImageIOException
-
fix_grayscale_gamma
protected BufferedImage fix_grayscale_gamma(Reference<BufferedImage> ref, int type) throws ImageIOException - Throws:
ImageIOException
-
size
Gets the size of an image.- Specified by:
size
in interfaceImageLoader
- Parameters:
name
- the image namein
- the input stream- Returns:
- the size of the image
- Throws:
BrokenImageException
- if the image is faultyUnrecognizedImageTypeException
- if the image type is not recognizedImageIOException
- if reading the image goes wrong
-