Package com.vuzix.ultralite
Class LVGLImage
java.lang.Object
com.vuzix.ultralite.LVGLImage
Represents an image in LVGL format. Use fromBitmap() to convert from Bitmap to LVGLImage.
- Since:
- 1.0.0
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
Maps RGB colors to 1 or 2 bit colors. -
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Constant for color format value LV_IMG_CF_INDEXED_1BITstatic final int
Constant for color format value LV_IMG_CF_INDEXED_2BIT -
Constructor Summary
ConstructorDescriptionLVGLImage
(int cf, int width, int height, android.graphics.Color[] colors, byte[] pixelData) Constructs a new LVGLImage. -
Method Summary
Modifier and TypeMethodDescriptionstatic LVGLImage
fromBitmap
(android.graphics.Bitmap bitmap, int cf) Converts an Android bitmap to LVGLImage.static LVGLImage
fromBitmap
(android.graphics.Bitmap bitmap, int cf, LVGLImage.ColorMapper mapper) Converts an Android bitmap to LVGLImage using the provided color mapper.int
getCf()
Get the color format (CF) of the imageandroid.graphics.Color[]
Get the color paletteint
Get the height of the imagebyte[]
Get the pixel data.int
getWidth()
Get the width of the image
-
Field Details
-
CF_INDEXED_1_BIT
public static final int CF_INDEXED_1_BITConstant for color format value LV_IMG_CF_INDEXED_1BIT- Since:
- 1.0.0
- See Also:
-
CF_INDEXED_2_BIT
public static final int CF_INDEXED_2_BITConstant for color format value LV_IMG_CF_INDEXED_2BIT- Since:
- 1.0.0
- See Also:
-
-
Constructor Details
-
LVGLImage
public LVGLImage(int cf, int width, int height, android.graphics.Color[] colors, byte[] pixelData) Constructs a new LVGLImage.- Parameters:
cf
- the color format, must be one of CF_INDEXED_1_BIT or CF_INDEXED_2_BITwidth
- the image width, no larger than 2048height
- the image height, no larger than 2048colors
- the color palette, must contain 2 colors for CF_INDEXED_1_BIT and 4 colors for CF_INDEXED_2_BITpixelData
- the image pixel data- Throws:
IllegalArgumentException
- if cf is not CF_INDEXED_1_BIT or CF_INDEXED_2_BIT, if colors is not the correct length, if width and height are zero or larger than 2048, if pixelData is null- Since:
- 1.0.0
-
-
Method Details
-
getCf
public int getCf()Get the color format (CF) of the image- Returns:
- int value of the color format
- Since:
- 1.0.0
-
getWidth
public int getWidth()Get the width of the image- Returns:
- width in pixels
- Since:
- 1.0.0
-
getHeight
public int getHeight()Get the height of the image- Returns:
- height in pixels
- Since:
- 1.0.0
-
getColors
public android.graphics.Color[] getColors()Get the color palette
Images in CF_INDEXED_1_BIT will have 2 color entries for indexes (0,1). Images in CF_INDEXED_2_BIT will have 4 color entries for indexes (0,1,2,3).
- Returns:
- Color[] array of colors associated with each encoded pixel color index
- Since:
- 1.0.0
-
getPixelData
public byte[] getPixelData()Get the pixel data.- Returns:
- byte[] array of pixels in packed form (for example: 4 pixels per byte in CF_INDEXED_2_BIT.)
- Since:
- 1.0.0
-
fromBitmap
Converts an Android bitmap to LVGLImage. Default color mapping will be used and is based on the color format provided. Default color mapping will convert the image to gray scale and choose an appropriate color from the palette. For more control, provide your own color mapper.- Parameters:
bitmap
- the source Bitmap, can be no larger than 2048x2048cf
- the color format, must be one of CF_INDEXED_1_BIT or CF_INDEXED_2_BIT- Returns:
- LVGLImage representation of the provided bitmap
- Throws:
IllegalArgumentException
- if bitmap is null, if cf is not CF_INDEXED_1_BIT or CF_INDEXED_2_BIT, if bitmap width and height are zero or larger than 2048- Since:
- 1.0.0
-
fromBitmap
public static LVGLImage fromBitmap(android.graphics.Bitmap bitmap, int cf, LVGLImage.ColorMapper mapper) Converts an Android bitmap to LVGLImage using the provided color mapper.- Parameters:
bitmap
- the source Bitmap, can be no larger than 2048x2048cf
- the color format, must be one of CF_INDEXED_1_BIT or CF_INDEXED_2_BITmapper
- a color mapper used to map colors to 1 or 2 bit- Returns:
- LVGLImage representation of the provided bitmap
- Throws:
IllegalArgumentException
- if bitmap or mapper is null, if cf is not CF_INDEXED_1_BIT or CF_INDEXED_2_BIT, if mapper provides wrong number of colors for the given cf, if bitmap width and height are zero or larger than 2048, if mapper provides an invalid index- Since:
- 1.0.0
-