public final class FileEncodedImage

  1. Object
  2. Image
  3. EncodedImage
  4. FileEncodedImage

ImplementsActionSource

An encoded image that stores the actual data of the encoded image in a disk file or resource and loads it only when necessary. The huge advantage is that RAM usage is practically none-existant, it is potentially very slow in worst case scenarios and has the other drawback of requiring the width/height in advanced to work properly.

Methods

public static FileEncodedImage create(String fileName, int width, int height)Creates an encoded image that maps to a local file thus allowing to seamlessly fetch files as needed.
public static FileEncodedImage create(String fileName, InputStream i, int width, int height) throws IOExceptionCreates an encoded image that maps to a local file thus allowing to seamlessly fetch files as needed.
public static FileEncodedImage create(String fileName, int width, int height, boolean keep)Creates an encoded image that maps to a local file thus allowing to seamlessly fetch files as needed.
public byte[] getImageData()Returns the byte array data backing the image allowing the image to be stored and discarded completely from RAM.

Inherited methods

Method details

create

public static FileEncodedImage create(String fileName, int width, int height)
Creates an encoded image that maps to a local file thus allowing to seamlessly fetch files as needed. This only works reasonably well for very small files.

Parameters

fileName String
the name of the file
width int
the width of the file or -1 if unknown (notice that this will improve performance)
height int
the height of the file or -1 if unknown (notice that this will improve performance)

Returns

image that will load the file seamlessly

create

public static FileEncodedImage create(String fileName, InputStream i, int width, int height) throws IOException
Creates an encoded image that maps to a local file thus allowing to seamlessly fetch files as needed. This only works reasonably well for very small files. This version of the method creates the file from an input stream

Parameters

fileName String
the name of the file
i InputStream
input stream from which to create the file
width int
the width of the file or -1 if unknown (notice that this will improve performance)
height int
the height of the file or -1 if unknown (notice that this will improve performance)

Returns

image that will load the file seamlessly

create

public static FileEncodedImage create(String fileName, int width, int height, boolean keep)
Creates an encoded image that maps to a local file thus allowing to seamlessly fetch files as needed. This only works reasonably well for very small files.

Parameters

fileName String
the name of the file
width int
the width of the file or -1 if unknown (notice that this will improve performance)
height int
the height of the file or -1 if unknown (notice that this will improve performance)
keep boolean
if set to true keeps the file in RAM once loaded

Returns

image that will load the file seamlessly

getImageData

public byte[] getImageData()
Returns the byte array data backing the image allowing the image to be stored and discarded completely from RAM.

Returns

byte array used to create the image, e.g. encoded PNG, JPEG etc.