# Class FileEncodedImageAsync

java.lang.Object
com.codename1.ui.Image
com.codename1.ui.EncodedImage
com.codename1.components.FileEncodedImageAsync

All Implemented Interfaces:
  `ActionSource`

public final class FileEncodedImageAsync extends EncodedImage
This class is identical to FileEncodedImage with the difference of using asynchronous loading for files (and the animation framework) which will not work for all cases (e.g. renderers) but could improve some performance/RAM aspects.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `animate()`
  `static FileEncodedImageAsync`
  `create(String fileName, byte[] placeholder, int width, int height)`
  Creates an encoded image that maps to a local file thus allowing to seamlessly fetch files as needed.
  `static FileEncodedImageAsync`
  `create(String fileName, Image placeholder)`
  Creates an encoded image that maps to a local file thus allowing to seamlessly fetch files as needed.
  `byte[]`
  `getImageData()`
  Returns the byte array data backing the image allowing the image to be stored and discarded completely from RAM.
  `protected Image`
  `getInternal()`
  Returns the actual image represented by the encoded image, this image will be cached in a weak/soft reference internally.
  `boolean`
  `isAnimation()`
  Returns true if this is an animated image
  `protected void`
  `resetCache()`
  A subclass might choose to load asynchroniously and reset the cache when the image is ready.

  ### Methods inherited from class EncodedImage

  `asyncLock, create, create, create, create, create, createFromImage, createFromRGB, createMulti, drawImage, drawImage, getGraphics, getHeight, getImage, getWidth, isLocked, isOpaque, lock, modifyAlpha, modifyAlpha, rotate, scale, scaled, scaledEncoded, scaledHeight, scaledSmallerRatio, scaledWidth, subImage, toRGB, unlock`

  ### Methods inherited from class Image

  `addActionListener, applyMask, applyMask, applyMaskAutoScale, createImage, createImage, createImage, createImage, createImage, createImage, createImage, createIndexed, createMask, createSVG, dispose, exifRotation, exifRotation, exifRotation, fill, fireChangedEvent, flipHorizontally, flipVertically, getExifOrientationTag, getExifOrientationTag, getImageName, getRGB, getRGB, getRGBCached, getSVGDocument, isAlphaMutableImageSupported, isJPEG, isPNG, isSVG, isSVGSupported, mirror, modifyAlphaWithTranslucency, removeActionListener, requiresDrawImage, rotate180Degrees, rotate270Degrees, rotate90Degrees, scaledLargerRatio, setImageName`

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Method Details

  - ### create

    public static FileEncodedImageAsync create(String fileName, byte[] placeholder, 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`: the name of the file

    - `placeholder`: a placeholder image until the actual image loads

    - `width`: the width of the file or -1 if unknown (notice that this will improve performance)

    - `height`: the height of the file or -1 if unknown (notice that this will improve performance)

    ###### Returns

    image that will load the file seamlessly

    ###### Deprecated

    use the version that accepts a name and a placeholderImage

  - ### create

    public static FileEncodedImageAsync create(String fileName, Image placeholder)

    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`: the name of the file

    - `placeholder`: an image that will occupy the space

    ###### Returns

    image that will load the file seamlessly

  - ### resetCache

    protected void resetCache()
    A subclass might choose to load asynchroniously and reset the cache when the image is ready.
    Overrides:
      `resetCache` in class `EncodedImage`

  - ### getInternal

    protected Image getInternal()

    Returns the actual image represented by the encoded image, this image will be cached in a weak/soft reference internally. This method is useful to detect when the system actually created an image instance. You shouldn't invoke this method manually!

    ###### Returns

    drawable image instance

    Overrides:
      `getInternal` in class `EncodedImage`

  - ### 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.

    Overrides:
      `getImageData` in class `EncodedImage`

  - ### animate

    public boolean animate()
    Overrides:
      `animate` in class `Image`

  - ### isAnimation

    public boolean isAnimation()

    Returns true if this is an animated image

    ###### Returns

    true if this image represents an animation

    Overrides:
      `isAnimation` in class `EncodedImage`