public class VectorImage extends Object
Modifier and Type | Method and Description |
---|---|
ResourceVectorImage |
filterImage(float[] colorMatrix)
Creates an image derived from this image, applying the given color matrix.
|
long |
getDuration()
Gets the duration of the vector image animation if the image is animated, otherwise 0.
|
float |
getHeight()
Gets the height of the vector image.
|
static VectorImage |
getImage(String resourcePath)
Gets a vector image from a path.
|
float |
getWidth()
Gets the width of the vector image.
|
public ResourceVectorImage filterImage(float[] colorMatrix)
The returned image is allocated dynamically and must be closed explicitly.
The given matrix is a 4x5 color matrix. It is organized like that:
redMultiplier x redInitialComponent + greenMultiplier x greenInitialComponent + blueMultiplier x blueInitialComponent + constant
Each component is clamped between 0x0 and 0xff.
Let A, R, G, B be the components of the initial color and the following array a color matrix:
{ rR, rG, rB, rA, rC,
gR, gG, gB, gA, gC,
bR, bG, bB, bA, bC,
aR, aG, aB, aA, aC }
The resulting color components are computed as:
resultRed = rR * R + rG * G + rB * B + rA * A + rC resultGreen = gR * R + gG * G + gB * B + gA * A + gC resultBlue = bR * R + bG * G + bB * B + bA * A + bC resultAlpha = aR * R + aG * G + aB * B + aA * A + aC
colorMatrix
- the color matrix used to transform colorsArrayIndexOutOfBoundsException
- if the given color matrix is shorter than 20 entriesVectorGraphicsException
- if the image has overlapping paths and the color matrix puts a non-opaque alpha levelpublic long getDuration()
public float getHeight()
public static VectorImage getImage(String resourcePath)
This method can only retrieve images which are in the internal image format defined by the MicroVG implementation. This operation does not require a dynamic allocation in order to store the image paths.
If the resource cannot be retrieved, a VectorGraphicsException
is thrown even if the resource is present
but requires a loading step.
resourcePath
- the path to get the image fromVectorGraphicsException
- if the image could not be retrieved for any reason (see
VectorGraphicsException.getErrorCode()
)public float getWidth()