lv_image.h

Defines

LV_IMAGE_DECLARE(var_name)

Use this macro to declare an image in a C file

Enums

enum lv_image_align_t

Image size mode, when image size and object size is different

Values:

enumerator LV_IMAGE_ALIGN_DEFAULT
enumerator LV_IMAGE_ALIGN_TOP_LEFT
enumerator LV_IMAGE_ALIGN_TOP_MID
enumerator LV_IMAGE_ALIGN_TOP_RIGHT
enumerator LV_IMAGE_ALIGN_BOTTOM_LEFT
enumerator LV_IMAGE_ALIGN_BOTTOM_MID
enumerator LV_IMAGE_ALIGN_BOTTOM_RIGHT
enumerator LV_IMAGE_ALIGN_LEFT_MID
enumerator LV_IMAGE_ALIGN_RIGHT_MID
enumerator LV_IMAGE_ALIGN_CENTER
enumerator LV_IMAGE_ALIGN_AUTO_TRANSFORM
enumerator LV_IMAGE_ALIGN_STRETCH
enumerator LV_IMAGE_ALIGN_TILE
enum [anonymous]

Values:

enumerator LV_PROPERTY_IMAGE_SRC
enumerator LV_PROPERTY_IMAGE_OFFSET_X
enumerator LV_PROPERTY_IMAGE_OFFSET_Y
enumerator LV_PROPERTY_IMAGE_ROTATION
enumerator LV_PROPERTY_IMAGE_PIVOT
enumerator LV_PROPERTY_IMAGE_SCALE
enumerator LV_PROPERTY_IMAGE_SCALE_X
enumerator LV_PROPERTY_IMAGE_SCALE_Y
enumerator LV_PROPERTY_IMAGE_BLEND_MODE
enumerator LV_PROPERTY_IMAGE_ANTIALIAS
enumerator LV_PROPERTY_IMAGE_INNER_ALIGN
enumerator LV_PROPERTY_IMAGE_END

Functions

lv_obj_t *lv_image_create(lv_obj_t *parent)

Create an image object

Parameters:

parent – pointer to an object, it will be the parent of the new image

Returns:

pointer to the created image

void lv_image_set_src(lv_obj_t *obj, const void *src)

Set the image data to display on the object

Parameters:
  • obj – pointer to an image object

  • src – 1) pointer to an lv_image_dsc_t descriptor (converted by LVGL's image converter) (e.g. &my_img) or 2) path to an image file (e.g. "S:/dir/img.bin")or 3) a SYMBOL (e.g. LV_SYMBOL_OK)

void lv_image_set_offset_x(lv_obj_t *obj, int32_t x)

Set an offset for the source of an image so the image will be displayed from the new origin.

Parameters:
  • obj – pointer to an image

  • x – the new offset along x axis.

void lv_image_set_offset_y(lv_obj_t *obj, int32_t y)

Set an offset for the source of an image. so the image will be displayed from the new origin.

Parameters:
  • obj – pointer to an image

  • y – the new offset along y axis.

void lv_image_set_rotation(lv_obj_t *obj, int32_t angle)

Set the rotation angle of the image. The image will be rotated around the set pivot set by lv_image_set_pivot() Note that indexed and alpha only images can't be transformed.

Note

if image_align is LV_IMAGE_ALIGN_STRETCH or LV_IMAGE_ALIGN_FIT rotation will be set to 0 automatically.

Parameters:
  • obj – pointer to an image object

  • angle – rotation in degree with 0.1 degree resolution (0..3600: clock wise)

void lv_image_set_pivot(lv_obj_t *obj, int32_t x, int32_t y)

Set the rotation center of the image. The image will be rotated around this point. x, y can be set with value of LV_PCT, lv_image_get_pivot will return the true pixel coordinate of pivot in this case.

Parameters:
  • obj – pointer to an image object

  • x – rotation center x of the image

  • y – rotation center y of the image

void lv_image_set_scale(lv_obj_t *obj, uint32_t zoom)

Set the zoom factor of the image. Note that indexed and alpha only images can't be transformed.

Parameters:
  • obj – pointer to an image object

  • zoom – the zoom factor. Example values:

    • 256 or LV_ZOOM_IMAGE_NONE: no zoom

    • <256: scale down

    • >256: scale up

    • 128: half size

    • 512: double size

void lv_image_set_scale_x(lv_obj_t *obj, uint32_t zoom)

Set the horizontal zoom factor of the image. Note that indexed and alpha only images can't be transformed.

Parameters:
  • obj – pointer to an image object

  • zoom – the zoom factor. Example values:

    • 256 or LV_ZOOM_IMAGE_NONE: no zoom

    • <256: scale down

    • >256: scale up

    • 128: half size

    • 512: double size

void lv_image_set_scale_y(lv_obj_t *obj, uint32_t zoom)

Set the vertical zoom factor of the image. Note that indexed and alpha only images can't be transformed.

Parameters:
  • obj – pointer to an image object

  • zoom – the zoom factor. Example values:

    • 256 or LV_ZOOM_IMAGE_NONE: no zoom

    • <256: scale down

    • >256: scale up

    • 128: half size

    • 512: double size

void lv_image_set_blend_mode(lv_obj_t *obj, lv_blend_mode_t blend_mode)

Set the blend mode of an image.

Parameters:
  • obj – pointer to an image object

  • blend_mode – the new blend mode

void lv_image_set_antialias(lv_obj_t *obj, bool antialias)

Enable/disable anti-aliasing for the transformations (rotate, zoom) or not. The quality is better with anti-aliasing looks better but slower.

Parameters:
  • obj – pointer to an image object

  • antialias – true: anti-aliased; false: not anti-aliased

void lv_image_set_inner_align(lv_obj_t *obj, lv_image_align_t align)

Set the image object size mode.

Note

if image_align is LV_IMAGE_ALIGN_STRETCH or LV_IMAGE_ALIGN_FIT rotation, scale and pivot will be overwritten and controlled internally.

Parameters:
  • obj – pointer to an image object

  • align – the new align mode.

void lv_image_set_bitmap_map_src(lv_obj_t *obj, const lv_image_dsc_t *src)

Set an A8 bitmap mask for the image.

Parameters:
  • obj – pointer to an image object

  • src – an lv_image_dsc_t bitmap mask source.

const void *lv_image_get_src(lv_obj_t *obj)

Get the source of the image

Parameters:

obj – pointer to an image object

Returns:

the image source (symbol, file name or ::lv-img_dsc_t for C arrays)

int32_t lv_image_get_offset_x(lv_obj_t *obj)

Get the offset's x attribute of the image object.

Parameters:

obj – pointer to an image

Returns:

offset X value.

int32_t lv_image_get_offset_y(lv_obj_t *obj)

Get the offset's y attribute of the image object.

Parameters:

obj – pointer to an image

Returns:

offset Y value.

int32_t lv_image_get_rotation(lv_obj_t *obj)

Get the rotation of the image.

Note

if image_align is LV_IMAGE_ALIGN_STRETCH or LV_IMAGE_ALIGN_FIT rotation will be set to 0 automatically.

Parameters:

obj – pointer to an image object

Returns:

rotation in 0.1 degrees (0..3600)

void lv_image_get_pivot(lv_obj_t *obj, lv_point_t *pivot)

Get the pivot (rotation center) of the image. If pivot is set with LV_PCT, convert it to px before return.

Parameters:
  • obj – pointer to an image object

  • pivot – store the rotation center here

int32_t lv_image_get_scale(lv_obj_t *obj)

Get the zoom factor of the image.

Parameters:

obj – pointer to an image object

Returns:

zoom factor (256: no zoom)

int32_t lv_image_get_scale_x(lv_obj_t *obj)

Get the horizontal zoom factor of the image.

Parameters:

obj – pointer to an image object

Returns:

zoom factor (256: no zoom)

int32_t lv_image_get_scale_y(lv_obj_t *obj)

Get the vertical zoom factor of the image.

Parameters:

obj – pointer to an image object

Returns:

zoom factor (256: no zoom)

lv_blend_mode_t lv_image_get_blend_mode(lv_obj_t *obj)

Get the current blend mode of the image

Parameters:

obj – pointer to an image object

Returns:

the current blend mode

bool lv_image_get_antialias(lv_obj_t *obj)

Get whether the transformations (rotate, zoom) are anti-aliased or not

Parameters:

obj – pointer to an image object

Returns:

true: anti-aliased; false: not anti-aliased

lv_image_align_t lv_image_get_inner_align(lv_obj_t *obj)

Get the size mode of the image

Parameters:

obj – pointer to an image object

Returns:

element of lv_image_align_t

const lv_image_dsc_t *lv_image_get_bitmap_map_src(lv_obj_t *obj)

Get the bitmap mask source.

Parameters:

obj – pointer to an image object

Returns:

an lv_image_dsc_t bitmap mask source.

Variables

const lv_obj_class_t lv_image_class