「App:Library:LVGL:docs:Others:Snapshot」の版間の差分

提供: robot-jp wiki
ナビゲーションに移動検索に移動
12行目: 12行目:
  
 
= Snapshot =
 
= Snapshot =
 +
{| class="wikitable"
 +
!英文
 +
!自動翻訳
 +
|-
 +
|
 
Snapshot provides APIs to take snapshot image for LVGL object together with its children. The image will look exactly like the object.
 
Snapshot provides APIs to take snapshot image for LVGL object together with its children. The image will look exactly like the object.
 +
|
 +
|}
 +
:[[App:Library:LVGL:docs:Others|戻る : Previous]]
 +
  
 
== Usage ==
 
== Usage ==
Simply call API <code>lv_snapshot_take</code> to generate the image descriptor which can be set as image object src using <code>lv_img_set_src</code>.
+
{| class="wikitable"
 +
!英文
 +
!自動翻訳
 +
|-
 +
|
 +
Simply call API <code style="color: #bb0000;">lv_snapshot_take</code> to generate the image descriptor which can be set as image object src using <code style="color: #bb0000;">lv_img_set_src</code>.
  
 
Note, only below color formats are supported for now:
 
Note, only below color formats are supported for now:
24行目: 38行目:
 
* LV_IMG_CF_ALPHA_4BIT
 
* LV_IMG_CF_ALPHA_4BIT
 
* LV_IMG_CF_ALPHA_8BIT
 
* LV_IMG_CF_ALPHA_8BIT
 
+
|
 +
|}
 +
:[[App:Library:LVGL:docs:Others|戻る : Previous]]
  
  
 
=== Free the Image ===
 
=== Free the Image ===
The memory <code>lv_snapshot_take</code> uses are dynamically allocated using <code>lv_mem_alloc</code>. Use API <code>lv_snapshot_free</code> to free the memory it takes. This will firstly free memory the image data takes, then the image descriptor.
+
{| class="wikitable"
 +
!英文
 +
!自動翻訳
 +
|-
 +
|
 +
The memory <code style="color: #bb0000;">lv_snapshot_take</code> uses are dynamically allocated using <code style="color: #bb0000;">lv_mem_alloc</code>. Use API <code style="color: #bb0000;">lv_snapshot_free</code> to free the memory it takes. This will firstly free memory the image data takes, then the image descriptor.
  
Take caution to free the snapshot but not delete the image object. Before free the memory, be sure to firstly unlink it from image object, using <code>lv_img_set_src(NULL)</code> and <code>lv_img_cache_invalidate_src(src)</code>.
+
Take caution to free the snapshot but not delete the image object. Before free the memory, be sure to firstly unlink it from image object, using <code style="color: #bb0000;">lv_img_set_src(NULL)</code> and <code style="color: #bb0000;">lv_img_cache_invalidate_src(src)</code>.
  
 
Below code snippet explains usage of this API.
 
Below code snippet explains usage of this API.
42行目: 63行目:
 
     lv_img_set_src(img_snapshot, snapshot);
 
     lv_img_set_src(img_snapshot, snapshot);
 
  }
 
  }
 +
|
 +
|}
 +
:[[App:Library:LVGL:docs:Others|戻る : Previous]]
 +
  
 
=== Use Existing Buffer ===
 
=== Use Existing Buffer ===
If the snapshot needs update now and then, or simply caller provides memory, use API <code>lv_res_t lv_snapshot_take_to_buf(lv_obj_t * obj, lv_img_cf_t cf, lv_img_dsc_t * dsc, void * buf, uint32_t buff_size);</code> for this case. It's caller's responsibility to alloc/free the memory.
+
{| class="wikitable"
 +
!英文
 +
!自動翻訳
 +
|-
 +
|
 +
If the snapshot needs update now and then, or simply caller provides memory, use API <code style="color: #bb0000;">lv_res_t lv_snapshot_take_to_buf(lv_obj_t * obj, lv_img_cf_t cf, lv_img_dsc_t * dsc, void * buf, uint32_t buff_size);</code> for this case. It's caller's responsibility to alloc/free the memory.
  
If snapshot is generated successfully, the image descriptor is updated and image data will be stored to provided <code>buf</code>.
+
If snapshot is generated successfully, the image descriptor is updated and image data will be stored to provided <code style="color: #bb0000;">buf</code>.
  
Note that snapshot may fail if provided buffer is not enough, which may happen when object size changes. It's recommended to use API <code>lv_snapshot_buf_size_needed</code> to check the needed buffer size in byte firstly and resize the buffer accordingly.
+
Note that snapshot may fail if provided buffer is not enough, which may happen when object size changes. It's recommended to use API <code style="color: #bb0000;">lv_snapshot_buf_size_needed</code> to check the needed buffer size in byte firstly and resize the buffer accordingly.
 +
|
 +
|}
 +
:[[App:Library:LVGL:docs:Others|戻る : Previous]]
  
  
56行目: 89行目:
  
 
=== Simple snapshot example ===
 
=== Simple snapshot example ===
 +
{| class="wikitable"
 +
!英文
 +
!自動翻訳
 +
|-
 +
|
 
[[ファイル:LVGL docs others snapshot 01.png|代替文=LVGL docs others snapshot 01|サムネイル|LVGL docs others snapshot 01]]
 
[[ファイル:LVGL docs others snapshot 01.png|代替文=LVGL docs others snapshot 01|サムネイル|LVGL docs others snapshot 01]]
 +
|
 +
|}
 +
:[[App:Library:LVGL:docs:Others|戻る : Previous]]
  
  
 
== API ==
 
== API ==
 +
{| class="wikitable"
 +
!英文
 +
!自動翻訳
 +
|-
 +
|
 
Functions
 
Functions
  
; <span id="_CPPv316lv_snapshot_takeP8lv_obj_t11lv_img_cf_t"></span><span id="_CPPv216lv_snapshot_takeP8lv_obj_t11lv_img_cf_t"></span><span id="lv_snapshot_take__lv_obj_tP.lv_img_cf_t"></span><span id="lv__snapshot_8h_1ac45005ac1ae1e130e2f62ed27237fe25" class="target"></span>lv_img_dsc_t *lv_snapshot_take(lv_obj_t *obj, lv_img_cf_t cf)[https://docs.lvgl.io/8.2/others/snapshot.html#_CPPv416lv_snapshot_takeP8lv_obj_t11lv_img_cf_t] <span id="_CPPv316lv_snapshot_takeP8lv_obj_t11lv_img_cf_t"></span><span id="_CPPv216lv_snapshot_takeP8lv_obj_t11lv_img_cf_t"></span><span id="lv_snapshot_take__lv_obj_tP.lv_img_cf_t"></span><span id="lv__snapshot_8h_1ac45005ac1ae1e130e2f62ed27237fe25" class="target"></span>
+
; lv_img_dsc_t *lv_snapshot_take(lv_obj_t *obj, lv_img_cf_t cf)  
 
: Take snapshot for object with its children.
 
: Take snapshot for object with its children.
:; Parameters[https://docs.lvgl.io/8.2/others/snapshot.html#_CPPv416lv_snapshot_takeP8lv_obj_t11lv_img_cf_t]
+
:; Parameters
 
::* obj -- The object to generate snapshot.
 
::* obj -- The object to generate snapshot.
 
::* cf -- color format for generated image.
 
::* cf -- color format for generated image.
70行目: 116行目:
 
:: a pointer to an image descriptor, or NULL if failed.
 
:: a pointer to an image descriptor, or NULL if failed.
  
; <span id="_CPPv316lv_snapshot_freeP12lv_img_dsc_t"></span><span id="_CPPv216lv_snapshot_freeP12lv_img_dsc_t"></span><span id="lv_snapshot_free__lv_img_dsc_tP"></span><span id="lv__snapshot_8h_1ad15bf2b95187202bc8e1ffa3b472c05c" class="target"></span>void lv_snapshot_free(lv_img_dsc_t *dsc)[https://docs.lvgl.io/8.2/others/snapshot.html#_CPPv416lv_snapshot_freeP12lv_img_dsc_t] <span id="_CPPv316lv_snapshot_freeP12lv_img_dsc_t"></span><span id="_CPPv216lv_snapshot_freeP12lv_img_dsc_t"></span><span id="lv_snapshot_free__lv_img_dsc_tP"></span><span id="lv__snapshot_8h_1ad15bf2b95187202bc8e1ffa3b472c05c" class="target"></span>
+
; void lv_snapshot_free(lv_img_dsc_t *dsc)  
: Free the snapshot image returned by [https://docs.lvgl.io/8.2/others/snapshot.html#_CPPv416lv_snapshot_freeP12lv_img_dsc_t]lv_snapshot_take  It will firstly free the data image takes, then the image descriptor.
+
: Free the snapshot image returned by lv_snapshot_take  It will firstly free the data image takes, then the image descriptor.
 
:; Parameters
 
:; Parameters
 
:: dsc -- The image descriptor generated by lv_snapshot_take.
 
:: dsc -- The image descriptor generated by lv_snapshot_take.
  
; <span id="_CPPv327lv_snapshot_buf_size_neededP8lv_obj_t11lv_img_cf_t"></span><span id="_CPPv227lv_snapshot_buf_size_neededP8lv_obj_t11lv_img_cf_t"></span><span id="lv_snapshot_buf_size_needed__lv_obj_tP.lv_img_cf_t"></span><span id="lv__snapshot_8h_1a54cd780d96deb1e7e787d312b8e19333" class="target"></span>uint32_t lv_snapshot_buf_size_needed(lv_obj_t *obj, lv_img_cf_t cf)[https://docs.lvgl.io/8.2/others/snapshot.html#_CPPv427lv_snapshot_buf_size_neededP8lv_obj_t11lv_img_cf_t] <span id="_CPPv327lv_snapshot_buf_size_neededP8lv_obj_t11lv_img_cf_t"></span><span id="_CPPv227lv_snapshot_buf_size_neededP8lv_obj_t11lv_img_cf_t"></span><span id="lv_snapshot_buf_size_needed__lv_obj_tP.lv_img_cf_t"></span><span id="lv__snapshot_8h_1a54cd780d96deb1e7e787d312b8e19333" class="target"></span>
+
; uint32_t lv_snapshot_buf_size_needed(lv_obj_t *obj, lv_img_cf_t cf)  
 
: Get the buffer needed for object snapshot image.
 
: Get the buffer needed for object snapshot image.
:; Parameters[https://docs.lvgl.io/8.2/others/snapshot.html#_CPPv427lv_snapshot_buf_size_neededP8lv_obj_t11lv_img_cf_t]
+
:; Parameters
 
::* obj -- The object to generate snapshot.
 
::* obj -- The object to generate snapshot.
 
::* cf -- color format for generated image.
 
::* cf -- color format for generated image.
83行目: 129行目:
 
:: the buffer size needed in bytes
 
:: the buffer size needed in bytes
  
; <span id="_CPPv323lv_snapshot_take_to_bufP8lv_obj_t11lv_img_cf_tP12lv_img_dsc_tPv8uint32_t"></span><span id="_CPPv223lv_snapshot_take_to_bufP8lv_obj_t11lv_img_cf_tP12lv_img_dsc_tPv8uint32_t"></span><span id="lv_snapshot_take_to_buf__lv_obj_tP.lv_img_cf_t.lv_img_dsc_tP.voidP.uint32_t"></span><span id="lv__snapshot_8h_1afc76d63d2a6c4fc7b4027f1a13075787" class="target"></span>lv_res_t lv_snapshot_take_to_buf(lv_obj_t *obj, lv_img_cf_t cf, lv_img_dsc_t *dsc, void *buf, uint32_t buff_size)[https://docs.lvgl.io/8.2/others/snapshot.html#_CPPv423lv_snapshot_take_to_bufP8lv_obj_t11lv_img_cf_tP12lv_img_dsc_tPv8uint32_t] <span id="_CPPv323lv_snapshot_take_to_bufP8lv_obj_t11lv_img_cf_tP12lv_img_dsc_tPv8uint32_t"></span><span id="_CPPv223lv_snapshot_take_to_bufP8lv_obj_t11lv_img_cf_tP12lv_img_dsc_tPv8uint32_t"></span><span id="lv_snapshot_take_to_buf__lv_obj_tP.lv_img_cf_t.lv_img_dsc_tP.voidP.uint32_t"></span><span id="lv__snapshot_8h_1afc76d63d2a6c4fc7b4027f1a13075787" class="target"></span>
+
; lv_res_t lv_snapshot_take_to_buf(lv_obj_t *obj, lv_img_cf_t cf, lv_img_dsc_t *dsc, void *buf, uint32_t buff_size)  
 
: Take snapshot for object with its children, save image info to provided buffer.
 
: Take snapshot for object with its children, save image info to provided buffer.
 
:; Parameters
 
:; Parameters
::* obj -- The[https://docs.lvgl.io/8.2/others/snapshot.html#_CPPv423lv_snapshot_take_to_bufP8lv_obj_t11lv_img_cf_tP12lv_img_dsc_tPv8uint32_t] object to generate snapshot.
+
::* obj -- The object to generate snapshot.
 
::* cf -- color format for generated image.
 
::* cf -- color format for generated image.
 
::* dsc -- image descriptor to store the image result.
 
::* dsc -- image descriptor to store the image result.
93行目: 139行目:
 
:; Returns
 
:; Returns
 
:: LV_RES_OK on success, LV_RES_INV on error.
 
:: LV_RES_OK on success, LV_RES_INV on error.
 
+
|
 
+
|}
 
 
----
 
 
:[[App:Library:LVGL:docs:Others|戻る : Previous]]
 
:[[App:Library:LVGL:docs:Others|戻る : Previous]]

2022年6月22日 (水) 21:22時点における版

https://docs.lvgl.io/8.2/others/snapshot.html

英文 自動翻訳


Snapshot

英文 自動翻訳

Snapshot provides APIs to take snapshot image for LVGL object together with its children. The image will look exactly like the object.

戻る : Previous


Usage

英文 自動翻訳

Simply call API lv_snapshot_take to generate the image descriptor which can be set as image object src using lv_img_set_src.

Note, only below color formats are supported for now:

  • LV_IMG_CF_TRUE_COLOR_ALPHA
  • LV_IMG_CF_ALPHA_1BIT
  • LV_IMG_CF_ALPHA_2BIT
  • LV_IMG_CF_ALPHA_4BIT
  • LV_IMG_CF_ALPHA_8BIT
戻る : Previous


Free the Image

英文 自動翻訳

The memory lv_snapshot_take uses are dynamically allocated using lv_mem_alloc. Use API lv_snapshot_free to free the memory it takes. This will firstly free memory the image data takes, then the image descriptor.

Take caution to free the snapshot but not delete the image object. Before free the memory, be sure to firstly unlink it from image object, using lv_img_set_src(NULL) and lv_img_cache_invalidate_src(src).

Below code snippet explains usage of this API.

void update_snapshot(lv_obj_t * obj, lv_obj_t * img_snapshot)
{
    lv_img_dsc_t* snapshot = (void*)lv_img_get_src(img_snapshot);
    if(snapshot) {
        lv_snapshot_free(snapshot);
    }
    snapshot = lv_snapshot_take(obj, LV_IMG_CF_TRUE_COLOR_ALPHA);
    lv_img_set_src(img_snapshot, snapshot);
}
戻る : Previous


Use Existing Buffer

英文 自動翻訳

If the snapshot needs update now and then, or simply caller provides memory, use API lv_res_t lv_snapshot_take_to_buf(lv_obj_t * obj, lv_img_cf_t cf, lv_img_dsc_t * dsc, void * buf, uint32_t buff_size); for this case. It's caller's responsibility to alloc/free the memory.

If snapshot is generated successfully, the image descriptor is updated and image data will be stored to provided buf.

Note that snapshot may fail if provided buffer is not enough, which may happen when object size changes. It's recommended to use API lv_snapshot_buf_size_needed to check the needed buffer size in byte firstly and resize the buffer accordingly.

戻る : Previous



Example

Simple snapshot example

英文 自動翻訳
LVGL docs others snapshot 01
LVGL docs others snapshot 01
戻る : Previous


API

英文 自動翻訳

Functions

lv_img_dsc_t *lv_snapshot_take(lv_obj_t *obj, lv_img_cf_t cf)
Take snapshot for object with its children.
Parameters
  • obj -- The object to generate snapshot.
  • cf -- color format for generated image.
Returns
a pointer to an image descriptor, or NULL if failed.
void lv_snapshot_free(lv_img_dsc_t *dsc)
Free the snapshot image returned by lv_snapshot_take It will firstly free the data image takes, then the image descriptor.
Parameters
dsc -- The image descriptor generated by lv_snapshot_take.
uint32_t lv_snapshot_buf_size_needed(lv_obj_t *obj, lv_img_cf_t cf)
Get the buffer needed for object snapshot image.
Parameters
  • obj -- The object to generate snapshot.
  • cf -- color format for generated image.
Returns
the buffer size needed in bytes
lv_res_t lv_snapshot_take_to_buf(lv_obj_t *obj, lv_img_cf_t cf, lv_img_dsc_t *dsc, void *buf, uint32_t buff_size)
Take snapshot for object with its children, save image info to provided buffer.
Parameters
  • obj -- The object to generate snapshot.
  • cf -- color format for generated image.
  • dsc -- image descriptor to store the image result.
  • buff -- the buffer to store image data.
  • buff_size -- provided buffer size in bytes.
Returns
LV_RES_OK on success, LV_RES_INV on error.
戻る : Previous