# Class StorageImage

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

All Implemented Interfaces:
  `ActionSource`

public final class StorageImage extends EncodedImage
An encoded image that stores the actual data of the encoded image in storage.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static StorageImage`
  `create(String fileName, byte[] data, int width, int height)`
  Creates an encoded image that maps to a storage file thus allowing to seamlessly cache images as needed.
  `static StorageImage`
  `create(String fileName, byte[] data, int width, int height, boolean keep)`
  Creates an encoded image that maps to a storage file thus allowing to seamlessly cache images as needed.
  `static StorageImage`
  `create(String fileName, int width, int height)`
  Creates an encoded image that maps to a storage file thus allowing to seamlessly cache images as needed.
  `static StorageImage`
  `create(String fileName, int width, int height, boolean keep)`
  Creates an encoded image that maps to a storage file thus allowing to seamlessly cache images as needed.
  `static StorageImage`
  `create(String fileName, InputStream data, int width, int height)`
  Creates an encoded image that maps to a storage file thus allowing to seamlessly cache images as needed.
  `byte[]`
  `getImageData()`
  Returns the byte array data backing the image allowing the image to be stored and discarded completely from RAM.

  ### Methods inherited from class EncodedImage

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

  ### Methods inherited from class Image

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

  ### Methods inherited from class Object

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

- ## Method Details

  - ### create

    public static StorageImage create(String fileName, byte[] data, int width, int height)

    Creates an encoded image that maps to a storage file thus allowing to seamlessly cache images as needed. This only works reasonably well for very small files.

    ###### Parameters

    - `fileName`: the name of the storage file

    - `data`: the data

    - `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 or null if the storage failed

  - ### create

    public static StorageImage create(String fileName, byte[] data, int width, int height, boolean keep)

    Creates an encoded image that maps to a storage file thus allowing to seamlessly cache images as needed. This only works reasonably well for very small files.

    ###### Parameters

    - `fileName`: the name of the storage file

    - `data`: the data

    - `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)

    - `keep`: if set to true keeps the file in RAM once loaded

    ###### Returns

    image that will load the file seamlessly or null if the storage failed

  - ### create

    public static StorageImage create(String fileName, InputStream data, int width, int height) throws IOException

    Creates an encoded image that maps to a storage file thus allowing to seamlessly cache images as needed. This only works reasonably well for very small files.

    ###### Parameters

    - `fileName`: the name of the storage file

    - `data`: the stream to cache

    - `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

    Throws:
      `IOException`

  - ### create

    public static StorageImage create(String fileName, int width, int height)

    Creates an encoded image that maps to a storage file thus allowing to seamlessly cache images as needed. This only works reasonably well for very small files.

    ###### Parameters

    - `fileName`: the name of the storage file

    - `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

  - ### create

    public static StorageImage create(String fileName, int width, int height, boolean keep)

    Creates an encoded image that maps to a storage file thus allowing to seamlessly cache images as needed. This only works reasonably well for very small files.

    ###### Parameters

    - `fileName`: the name of the storage file

    - `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)

    - `keep`: 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.

    Overrides:
      `getImageData` in class `EncodedImage`