Package VASSAL.tools.image
Class ImageIOImageLoader
java.lang.Object
VASSAL.tools.image.ImageIOImageLoader
- All Implemented Interfaces:
ImageLoader
public class ImageIOImageLoader extends Object implements 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
BufferedImages with a predictable type.- Since:
- 3.1.0
- Author:
- Joel Uckelman
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static interfaceImageIOImageLoader.Wrapper<T> -
Field Summary
Fields Modifier and Type Field Description protected static ImageIOImageLoader.Wrapper<BufferedImage>readImageA functor for reading images.protected static ImageIOImageLoader.Wrapper<Dimension>readSizeA functor for reading image dimensions.protected ImageTypeConvertertconvprotected static booleanYCbCrBug -
Constructor Summary
Constructors Constructor Description ImageIOImageLoader(ImageTypeConverter tconv)Create an image loader. -
Method Summary
Modifier and Type Method Description protected BufferedImagefix_tRNS(Reference<BufferedImage> ref, int tRNS, int type)protected BufferedImagefix_YCbCr(Reference<BufferedImage> ref, int type)BufferedImageload(String name, InputStream in, int typeIfOpaque, int typeIfTransparent, boolean managed)Loads an image.Dimensionsize(String name, InputStream in)Gets the size of an image.protected <T> TwrapImageIO(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- theImageTypeConverterto use for type conversions
-
-
Method Details
-
load
public BufferedImage load(String name, InputStream in, int typeIfOpaque, int typeIfTransparent, boolean managed) throws ImageIOExceptionLoads an image.- Specified by:
loadin interfaceImageLoader- Parameters:
name- the image namein- the input streamtypeIfOpaque- the requested image type for opaque imagestypeIfTransparent- the requested image type for transparent imagesmanaged-trueif 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
-
size
Gets the size of an image.- Specified by:
sizein 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
-