public abstract class

Image

extends Object
java.lang.Object
   ↳ net.pierrox.lightning_launcher.script.api.Image
Known Direct Subclasses

Class Overview

Utility class to manipulate images (icons, backgrounds, etc.). This is the base class for various kind of images. Each image type (bitmap, nine patch, animation, scripted) have their own set of features. Please refer to their respective documentation.

Summary

Public Methods
static ImageAnimation createAnimation(int width, int height, int count, int duration, int loopCount)
Create a blank animation: frames are created fully transparent and need to be drawn.
static Image createImage(String path)
Create an image from the specified file.
static ImageBitmap createImage(int width, int height)
Create a blank new image of the specified size.
static Image createImage(String pkg, String name)
Create an image from a package and a resource name.
static ImageScript createImage(Scriptable object, int width, int height)
Create an image whose content is drawn using a script.
static ImageBitmap createTextIcon(String code, int size, int fgColor, int bgColor, Typeface typeface)
Create an icon using text.
void delete()
Delete this image from persistent storage (if loaded from a file).
abstract int getHeight()
Return the image height
String getType()
Return the type of this image.
abstract int getWidth()
Return the image width
boolean isNinePatch()
This method is deprecated. use #getType instead
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public static ImageAnimation createAnimation (int width, int height, int count, int duration, int loopCount)

Create a blank animation: frames are created fully transparent and need to be drawn. Notes: animations created this way are memory expensive and cannot be persisted (yet). This means that Shortcut.setCustomIcon() wont't work, but Shortcut.setImage() will.

Parameters
width image width
height image height
count number of frames to allocate
duration default frame duration
loopCount initial number of loops to play, use 0 for infinite
Returns
  • an animation or null in case of error (most likely out of memory)

public static Image createImage (String path)

Create an image from the specified file.

Parameters
path path of the image
Returns
  • can return null if an image cannot be read from the file (not an image or not enough memory)

public static ImageBitmap createImage (int width, int height)

Create a blank new image of the specified size. Pixel format is always ARGB 8888. Take care when creating images since it can rapidly exhaust memory and lead to a crash.

Returns
  • can return null if not enough memory

public static Image createImage (String pkg, String name)

Create an image from a package and a resource name. For instance:LL.createImage("net.pierrox.lightning_launcher_extreme", "icon") The density used is either the one given by ActivityManager.getLauncherLargeIconDensity if available, or the current one.

Parameters
pkg name of the package, use "android" to access system resources.
name name of the drawable resource
Returns
  • can return null if an image cannot be read from the package (unknown package, wrong resource name or not enough memory)

public static ImageScript createImage (Scriptable object, int width, int height)

Create an image whose content is drawn using a script. This can be used for memory efficient graphics and animations. Please refer to ImageScript for the documentation on how to use it.

Parameters
object the set of functions
width the prefered image width, use -1 for as big as possible
height the prefered image height, use -1 for as big as possible

public static ImageBitmap createTextIcon (String code, int size, int fgColor, int bgColor, Typeface typeface)

Create an icon using text. This function is intended to be used with an icon font to create high res icons.

Parameters
code character to use
size icons are square : width = height = size
fgColor foreground color
bgColor background color
typeface typeface to use, use the built-in icon typeface if null

public void delete ()

Delete this image from persistent storage (if loaded from a file).

public abstract int getHeight ()

Return the image height

public String getType ()

Return the type of this image.

Returns
  • one of BITMAP, NINE_PATCH, ANIMATION, SVG

public abstract int getWidth ()

Return the image width

public boolean isNinePatch ()

This method is deprecated.
use #getType instead