# Class ComponentImage.EncodedWrapper

java.lang.Object
com.codename1.ui.Image
com.codename1.ui.EncodedImage
com.codename1.ui.ComponentImage.EncodedWrapper

All Implemented Interfaces:
  `ActionSource`

Enclosing class:
  `ComponentImage`

public class ComponentImage.EncodedWrapper extends EncodedImage
A wrapper for ComponentImage to convert it to an EncodedImage.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected Image`
  `getInternal()`
  Returns the actual image represented by the encoded image, this image will be cached in a weak/soft reference internally.
  `Image`
  `scaled(int width, int height)`
  Returns a scaled version of this image image using the given width and height, this is a fast algorithm that preserves translucent information.
  `EncodedImage`
  `scaledEncoded(int width, int height)`
  Performs scaling using ImageIO to generate an encoded Image

  ### Methods inherited from class EncodedImage

  `asyncLock, create, create, create, create, create, createFromImage, createFromRGB, createMulti, drawImage, drawImage, getGraphics, getHeight, getImage, getImageData, getWidth, isAnimation, isLocked, isOpaque, lock, modifyAlpha, modifyAlpha, resetCache, rotate, scale, scaledHeight, scaledSmallerRatio, scaledWidth, subImage, toRGB, unlock`
  Modifier and Type
  Method
  Description
  `void`
  `asyncLock(Image internal)`
  Async lock is the equivalent of a lock operation, however it uses the given image as the hard cache and performs the actual image loading asynchronously.
  `static EncodedImage`
  `create(byte[] data)`
  Creates an image from the given byte array
  `static EncodedImage`
  `create(byte[] data, int width, int height, boolean opacity)`
  Creates an image from the given byte array with the variables set appropriately.
  `static EncodedImage`
  `create(InputStream i)`
  Creates an image from the input stream
  `static EncodedImage`
  `create(InputStream i, int size)`
  Creates an image from the input stream, this version of the method is somewhat faster than the version that doesn't accept size
  `static EncodedImage`
  `create(String i)`
  Creates an image from the input stream
  `static EncodedImage`
  `createFromImage(Image i, boolean jpeg)`
  Converts an image to encoded image
  `static Image`
  `createFromRGB(int[] argb, int width, int height, boolean jpeg)`
  Tries to create an encoded image from RGB which is more efficient, however if this fails it falls back to regular RGB image.
  `static EncodedImage`
  `createMulti(int[] dpis, byte[][] data)`
  Creates an encoded image that acts as a multi-image, DO NOT USE THIS METHOD.
  `protected void`
  `drawImage(Graphics g, Object nativeGraphics, int x, int y)`
  Callback invoked internally by Codename One to draw the image/frame onto the display.
  `protected void`
  `drawImage(Graphics g, Object nativeGraphics, int x, int y, int w, int h)`
  Callback invoked internally by Codename One to draw the image/frame onto the display.
  `Graphics`
  `getGraphics()`
  If this is a mutable image a graphics object allowing us to draw on it is returned.
  `int`
  `getHeight()`
  Returns the height of the image
  `Object`
  `getImage()`
  Returns the platform specific image implementation, warning the implementation class can change between revisions of Codename One and platforms.
  `byte[]`
  `getImageData()`
  Returns the byte array data backing the image allowing the image to be stored and discarded completely from RAM.
  `int`
  `getWidth()`
  Returns the width of the image
  `boolean`
  `isAnimation()`
  Returns true if this is an animated image
  `boolean`
  `isLocked()`
  Returns true if the image is locked
  `boolean`
  `isOpaque()`
  Indicates whether this image is opaque or not
  `void`
  `lock()`
  This callback indicates that a component pointing at this image is initialized, this allows an image to make performance sensitive considerations e.g.
  `Image`
  `modifyAlpha(byte alpha)`
  Creates a new image instance with the alpha channel of opaque/translucent pixels within the image using the new alpha value.
  `Image`
  `modifyAlpha(byte alpha, int removeColor)`
  Creates a new image instance with the alpha channel of opaque/translucent pixels within the image using the new alpha value.
  `protected void`
  `resetCache()`
  A subclass might choose to load asynchroniously and reset the cache when the image is ready.
  `Image`
  `rotate(int degrees)`
  Returns an instance of this image rotated by the given number of degrees.
  `void`
  `scale(int width, int height)`
  Scale the image to the given width and height, this is a fast algorithm that preserves translucent information
  `Image`
  `scaledHeight(int height)`
  Scales the image to the given height while updating the width based on the aspect ratio of the height
  `Image`
  `scaledSmallerRatio(int width, int height)`
  Scales the image while maintaining the aspect ratio to the smaller size image
  `Image`
  `scaledWidth(int width)`
  Scales the image to the given width while updating the height based on the aspect ratio of the width
  `Image`
  `subImage(int x, int y, int width, int height, boolean processAlpha)`
  Extracts a subimage from the given image allowing us to breakdown a single large image into multiple smaller images in RAM, this actually creates a standalone version of the image for use.
  `void`
  `toRGB(RGBImage image, int destX, int destY, int x, int y, int width, int height)`
  Extracts data from this image into the given RGBImage
  `void`
  `unlock()`
  This callback indicates that a component pointing at this image is now deinitilized This method may be invoked multiple times.

  ### Methods inherited from class Image

  `addActionListener, animate, 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`
  Modifier and Type
  Method
  Description
  `void`
  `addActionListener(ActionListener l)`
  Adds ActionListener to receive action events form this source.
  `boolean`
  `animate()`
  Advances this image's animation state, if it is animated.
  `Image`
  `applyMask(Object mask)`
  Applies the given alpha mask onto this image and returns the resulting image see the createMask method for indication on how to convert an image into an alpha mask.
  `Image`
  `applyMask(Object mask, int x, int y)`
  Applies the given alpha mask onto this image and returns the resulting image see the createMask method for indication on how to convert an image into an alpha mask.
  `Image`
  `applyMaskAutoScale(Object mask)`
  Applies the given alpha mask onto this image and returns the resulting image see the createMask method for indication on how to convert an image into an alpha mask.
  `static Image`
  `createImage(byte[] bytes, int offset, int len)`
  creates an image from a given byte array data
  `static Image`
  `createImage(int[] rgb, int width, int height)`
  creates an image from an RGB image
  `static Image`
  `createImage(int width, int height)`
  Creates a white opaque mutable image that may be manipulated using `#getGraphics()`.
  `static Image`
  `createImage(int width, int height, int fillColor)`
  Creates a mutable image that may be manipulated using `#getGraphics()`.
  `static Image`
  `createImage(InputStream stream)`
  creates an image from an InputStream
  `static Image`
  `createImage(Object nativeImage)`
  creates an image from the given native image (e.g. MIDP image object)
  `static Image`
  `createImage(String path)`
  Creates an image from a path.
  `static Image`
  `createIndexed(int width, int height, int[] palette, byte[] data)`
  Creates an indexed image with byte data this method may return a native indexed image rather than an instance of the IndexedImage class
  `Object`
  `createMask()`
  Creates a mask from the given image, a mask can be used to apply an arbitrary alpha channel to any image.
  `static Image`
  `createSVG(String baseURL, boolean animated, byte[] data)`
  Creates an SVG Image from the given byte array data and the base URL, this method will throw an exception if SVG is unsupported.
  `void`
  `dispose()`
  DO NOT CALL THIS METHOD UNLESS YOU KNOW WHAT YOU ARE DOING, IT WILL CAUSE PLATFORM SPECIFC CRASHES OTHERWISE! Images dispose automatically for most cases except for very rare special cases.
  `static Image`
  `exifRotation(String capturedImage)`
  The main use case of this method is the automatic rotation and flipping of an image returned from the camera or from the gallery, preserving the original format (jpeg or png); it detects the Exif Orientation Tag, if available (all the possible Exif Orientation Tag values are supported); transparency is not preserved.
  `static Image`
  `exifRotation(String capturedImage, String rotatedImage)`
  The main use case of this method is the automatic rotation and flipping of an image returned from the camera or from the gallery, preserving the original format (jpeg or png); it detects the Exif Orientation Tag, if available (all the possible Exif Orientation Tag values are supported); transparency is not preserved.
  `static Image`
  `exifRotation(String capturedImage, String rotatedImage, int maxSize)`
  The main use case of this method is the automatic rotation and flipping of an image returned from the camera or from the gallery, preserving the original format (jpeg or png); it detects the Exif Orientation Tag, if available (all the possible Exif Orientation Tag values are supported); transparency is not preserved.
  `Image`
  `fill(int width, int height)`
  Resizes/crops the image so that its center fills the given dimensions.
  `void`
  `fireChangedEvent()`
  `Image`
  `flipHorizontally(boolean maintainOpacity)`
  Flips this image on the horizontal axis
  `Image`
  `flipVertically(boolean maintainOpacity)`
  Flips this image on the vertical axis
  `static int`
  `getExifOrientationTag(InputStream is)`
  Gets the EXIF orientation tag of an image, if it's available.
  `static int`
  `getExifOrientationTag(String path)`
  Gets the EXIF orientation tag of an image if it's available.
  `String`
  `getImageName()`
  The name of the image is set for some images mostly to ease the debugging of Codename One application
  `int[]`
  `getRGB()`
  Returns the content of this image as a newly created ARGB array.
  `void`
  `getRGB(int[] rgbData)`
  Returns the content of this image in the supplied ARGB array.
  `int[]`
  `getRGBCached()`
  Returns the content of this image as a newly created ARGB array or a cached instance if possible.
  `Object`
  `getSVGDocument()`
  Returns a platform specific DOM object that can be manipulated by the user to change the SVG Image
  `static boolean`
  `isAlphaMutableImageSupported()`
  Returns true if mutable images support alpha transparency
  `static boolean`
  `isJPEG(InputStream inputStream)`
  Very fast method to detect if the given inputStream is a JPEG image (according to its guessed mime type)
  `static boolean`
  `isPNG(InputStream inputStream)`
  Very fast method to detect if the given inputStream is a PNG image (according to its guessed mime type)
  `boolean`
  `isSVG()`
  Indicates if this image represents an SVG file or a bitmap file
  `static boolean`
  `isSVGSupported()`
  Indicates whether the underlying platform supports creating an SVG Image
  `Image`
  `mirror()`
  Creates a mirror image for the given image which is useful for some RTL scenarios.
  `Image`
  `modifyAlphaWithTranslucency(byte alpha)`
  Creates a new image instance with the alpha channel of opaque pixels within the image using the new alpha value.
  `void`
  `removeActionListener(ActionListener l)`
  Removes ActionListener so that it will no longer receive events from this source.
  `boolean`
  `requiresDrawImage()`
  New label optimizations don't invoke drawImage and instead just pass the native image directly to the underlying renderer.
  `Image`
  `rotate180Degrees(boolean maintainOpacity)`
  Rotates the image by 180 degrees
  `Image`
  `rotate270Degrees(boolean maintainOpacity)`
  Rotates the image by 270 degrees while changing the ratio of the picture
  `Image`
  `rotate90Degrees(boolean maintainOpacity)`
  Rotates this image by 90 degrees while changing the ratio of the picture
  `Image`
  `scaledLargerRatio(int width, int height)`
  Scales the image while maintaining the aspect ratio to the larger size image
  `void`
  `setImageName(String imageName)`
  The name of the image is set for some images mostly to ease the debugging of Codename One application

  ### Methods inherited from class Object

  `clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`
  Modifier and Type
  Method
  Description
  `protected Object`
  `clone()`
  `boolean`
  `equals(Object obj)`
  Indicates whether some other object is "equal to" this one.
  `final Class`
  `getClass()`
  Returns the runtime class of an object.
  `int`
  `hashCode()`
  Returns a hash code value for the object.
  `final void`
  `notify()`
  Wakes up a single thread that is waiting on this object's monitor.
  `final void`
  `notifyAll()`
  Wakes up all threads that are waiting on this object's monitor.
  `String`
  `toString()`
  Returns a string representation of the object.
  `final void`
  `wait()`
  Causes current thread to wait until another thread invokes the method or the method for this object.
  `final void`
  `wait(long timeout)`
  Causes current thread to wait until either another thread invokes the method or the method for this object, or a specified amount of time has elapsed.
  `final void`
  `wait(long timeout, int nanos)`
  Causes current thread to wait until another thread invokes the method or the method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed.

- ## Method Details

  - ### scaledEncoded

    public EncodedImage scaledEncoded(int width, int height)

    Performs scaling using ImageIO to generate an encoded Image

    ###### Parameters

    - `width`: the width of the image, -1 to scale based on height and preserve aspect ratio

    - `height`: the height of the image, -1 to scale based on width and preserve aspect ratio

    ###### Returns

    new encoded image

    Overrides:
      `scaledEncoded` in class `EncodedImage`

  - ### scaled

    public Image scaled(int width, int height)

    Returns a scaled version of this image image using the given width and height, this is a fast algorithm that preserves translucent information. The method accepts -1 to preserve aspect ratio in the given axis.

    ###### Parameters

    - `width`: width for the scaling

    - `height`: height of the scaled image

    ###### Returns

    new image instance scaled to the given height and width

    Overrides:
      `scaled` 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`