Package VASSAL.tools.image
Class FileImageTypeConverter
java.lang.Object
VASSAL.tools.image.FileImageTypeConverter
- All Implemented Interfaces:
ImageTypeConverter
public class FileImageTypeConverter extends Object implements ImageTypeConverter
Convert a
BufferedImage to a different type by caching image
data on disk.- Since:
- 3.2.0
- Author:
- Joel Uckelman
-
Field Summary
Fields Modifier and Type Field Description protected TemporaryFileFactorytfactory -
Constructor Summary
Constructors Constructor Description FileImageTypeConverter(TemporaryFileFactory tfactory)Create a converter. -
Method Summary
Modifier and Type Method Description BufferedImageconvert(Reference<BufferedImage> ref, int type)Converts an image to the given type.protected voidread(InputStream in, BufferedImage dst)protected voidwrite(BufferedImage src, OutputStream out)
-
Field Details
-
tfactory
-
-
Constructor Details
-
FileImageTypeConverter
Create a converter.- Parameters:
tmp- the temporary file to use as a cache
-
-
Method Details
-
convert
Converts an image to the given type. WARNING: When this method is called, the sole reference to the image must be the one held byrefin order to allow the source image to be garbage collected after the image data is written to disk.- Specified by:
convertin interfaceImageTypeConverter- Parameters:
ref- a holder for the imagetype- the type of image to return- Returns:
- a converted image
- Throws:
ImageIOException- if something goes wrong
-
write
- Throws:
IOException
-
read
- Throws:
IOException
-