「App:Library:LVGL:docs:Others:Snapshot」の版間の差分
(同じ利用者による、間の6版が非表示) | |||
20行目: | 20行目: | ||
The image will look exactly like the object. | The image will look exactly like the object. | ||
− | | | + | |スナップショットは、LVGLオブジェクトのスナップショットイメージをその子と一緒に取得するためのAPIを提供します。 |
+ | |||
+ | 画像はオブジェクトとまったく同じように見えます。 | ||
|} | |} | ||
:[[App:Library:LVGL:docs:Others|戻る : Previous]] | :[[App:Library:LVGL:docs:Others|戻る : Previous]] | ||
41行目: | 43行目: | ||
* LV_IMG_CF_ALPHA_8BIT | * LV_IMG_CF_ALPHA_8BIT | ||
| | | | ||
+ | |||
+ | |||
+ | API<code style="color: #bb0000;">lv_snapshot_take</code>を呼び出すだけで、<code style="color: #bb0000;">lv_img_set_src</code>を使用して画像オブジェクトsrcとして設定できる画像記述子を生成できます。 | ||
+ | |||
+ | 現在、以下のカラーフォーマットのみがサポートされていることに注意してください。 | ||
+ | |||
+ | * 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 | ||
|} | |} | ||
:[[App:Library:LVGL:docs:Others|戻る : Previous]] | :[[App:Library:LVGL:docs:Others|戻る : Previous]] | ||
53行目: | 66行目: | ||
The memory <code style="color: #bb0000;">lv_snapshot_take</code> uses are dynamically allocated using <code style="color: #bb0000;">lv_mem_alloc</code>. | 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 | + | Use API <code style="color: #bb0000;">lv_snapshot_free</code> to free the memory it takes. |
− | 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>. | + | 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 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. | ||
70行目: | 87行目: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
| | | | ||
+ | |||
+ | |||
+ | |||
+ | メモリ<code style="color: #bb0000;">lv_snapshot_take</code>の使用は、<code style="color: #bb0000;">lv_mem_alloc</code>を使用して動的に割り当てられます。 | ||
+ | |||
+ | API<code style="color: #bb0000;">lv_snapshot_free</code>を使用して、必要なメモリを解放します。 | ||
+ | |||
+ | これにより、最初に画像データが使用するメモリが解放され、次に画像記述子が解放されます。 | ||
+ | |||
+ | |||
+ | スナップショットを解放するように注意してください。 | ||
+ | |||
+ | ただし、イメージオブジェクトは削除しないでください。 | ||
+ | |||
+ | メモリを解放する前に、必ず<code style="color: #bb0000;">lv_img_set_src(NULL)</code>と<code style="color: #bb0000;">lv_img_cache_invalidate_src(src)</code>を使用して、まず画像オブジェクトからメモリのリンクを解除してください。 | ||
+ | |||
+ | 以下のコードスニペットは、このAPIの使用法を説明しています。 | ||
+ | <syntaxhighlight lang="C++" style="border:1px dashed gray;"> | ||
+ | void update_snapshot (lv_obj_t * obj 、 lv_obj_t * img_snapshot ) | ||
+ | { | ||
+ | lv_img_dsc_t * スナップショット = (void * )lv_img_get_src (img_snapshot ) | ||
+ | if (snapshot ) { | ||
+ | lv_snapshot_free (snapshot ) | ||
+ | } | ||
+ | スナップショット = lv_snapshot_take (obj 、 LV_IMG_CF_TRUE_COLOR_ALPHA ) | ||
+ | lv_img_set_src (img_snapshot 、 snapshot); | ||
+ | } | ||
+ | </syntaxhighlight> | ||
|} | |} | ||
:[[App:Library:LVGL:docs:Others|戻る : Previous]] | :[[App:Library:LVGL:docs:Others|戻る : Previous]] | ||
79行目: | 124行目: | ||
|- | |- | ||
| | | | ||
− | 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 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 style="color: #bb0000;">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>. | ||
87行目: | 135行目: | ||
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. | 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. | ||
− | | | + | |スナップショットを時々更新する必要がある場合、または単に呼び出し元がメモリを提供する場合は、この場合は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>を使用してください。 |
+ | |||
+ | |||
+ | メモリを割り当て/解放するのは発信者の責任です。 | ||
+ | |||
+ | スナップショットが正常に生成されると、イメージ記述子が更新され、イメージデータが提供された<code style="color: #bb0000;">buf</code>に保存されます。 | ||
+ | |||
+ | |||
+ | 提供されたバッファが十分でない場合、スナップショットが失敗する可能性があることに注意してください。 | ||
+ | |||
+ | これは、オブジェクトサイズが変更されたときに発生する可能性があります。 | ||
+ | |||
+ | API<code style="color: #bb0000;">lv_snapshot_buf_size_needed</code>を使用して、最初に必要なバッファサイズをバイト単位で確認し、それに応じてバッファのサイズを変更することをお勧めします。 | ||
|} | |} | ||
:[[App:Library:LVGL:docs:Others|戻る : Previous]] | :[[App:Library:LVGL:docs:Others|戻る : Previous]] | ||
95行目: | 155行目: | ||
== Example == | == Example == | ||
− | |||
=== Simple snapshot example === | === Simple snapshot example === | ||
{| class="wikitable" | {| class="wikitable" | ||
116行目: | 175行目: | ||
Functions | Functions | ||
− | <span style="background-color: #e7f2fa; color: #2980b9;"> | + | <span style="background-color: #e7f2fa; color: #2980b9;"> *lv_snapshot_take( *obj, cf) </span> |
: Take snapshot for object with its children. | : Take snapshot for object with its children. | ||
:'''Parameters''' | :'''Parameters''' | ||
124行目: | 183行目: | ||
:: a pointer to an image descriptor, or NULL if failed. | :: a pointer to an image descriptor, or NULL if failed. | ||
− | <span style="background-color: #e7f2fa; color: #2980b9;">void lv_snapshot_free( | + | <span style="background-color: #e7f2fa; color: #2980b9;">void lv_snapshot_free( *dsc) </span> |
− | : Free the snapshot image returned by | + | : Free the snapshot image returned by 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 style="background-color: #e7f2fa; color: #2980b9;">uint32_t lv_snapshot_buf_size_needed( | + | <span style="background-color: #e7f2fa; color: #2980b9;">uint32_t lv_snapshot_buf_size_needed( *obj, cf) </span> |
: Get the buffer needed for object snapshot image. | : Get the buffer needed for object snapshot image. | ||
:'''Parameters''' | :'''Parameters''' | ||
137行目: | 196行目: | ||
:: the buffer size needed in bytes | :: the buffer size needed in bytes | ||
− | <span style="background-color: #e7f2fa; color: #2980b9;">lv_res_t lv_snapshot_take_to_buf( | + | <span style="background-color: #e7f2fa; color: #2980b9;">lv_res_t lv_snapshot_take_to_buf( *obj, cf, *dsc, void *buf, uint32_t buff_size) </span> |
: 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''' | ||
148行目: | 207行目: | ||
:: LV_RES_OK on success, LV_RES_INV on error. | :: LV_RES_OK on success, LV_RES_INV on error. | ||
| | | | ||
+ | |||
+ | |||
+ | 機能 | ||
+ | |||
+ | <span style="background-color:#e7f2fa;color:#2980b9;">'''lv_img_dsc_t''' * lv_snapshot_take( '''lv_obj_t''' * obj、 '''lv_img_cf_t''' cf)</span> | ||
+ | |||
+ | : オブジェクトとその子のスナップショットを作成します。 | ||
+ | : '''パラメーター''' | ||
+ | ::* '''obj-'''スナップショットを生成するオブジェクト。 | ||
+ | ::* '''cf--'''生成された画像のカラーフォーマット。 | ||
+ | : '''戻り値''' | ||
+ | :: 画像記述子へのポインタ。失敗した場合はNULL。 | ||
+ | |||
+ | <span style="background-color:#e7f2fa;color:#2980b9;">void lv_snapshot_free('''lv_img_dsc_t''' * dsc)</span> | ||
+ | |||
+ | : <font class="goog-text-highlight">スナップショットは、LVGLオブジェクトのスナップショットイメージをその子と一緒に取得するためのAPIを提供します。</font>'''lv_snapshot_take'''によって返されたスナップショットイメージ を解放します。最初にデータイメージが取得し、次にイメージ記述子が解放されます。 | ||
+ | : '''パラメーター''' | ||
+ | :: '''dsc''' -lv_snapshot_takeによって生成された画像記述子。 | ||
+ | |||
+ | <span style="background-color:#e7f2fa;color:#2980b9;">uint32_t lv_snapshot_buf_size_needed('''lv_obj_t''' * obj、'''lv_img_cf_t''' cf)</span> | ||
+ | |||
+ | : オブジェクトスナップショットイメージに必要なバッファを取得します。 | ||
+ | : '''パラメーター''' | ||
+ | ::* '''obj-'''スナップショットを生成するオブジェクト。 | ||
+ | ::* '''cf--'''生成された画像のカラーフォーマット。 | ||
+ | : '''戻り値''' | ||
+ | :: 必要なバッファサイズ(バイト単位) | ||
+ | |||
+ | <span style="background-color:#e7f2fa;color:#2980b9;">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)</span> | ||
+ | |||
+ | : オブジェクトとその子のスナップショットを作成し、提供されたバッファに画像情報を保存します。 | ||
+ | : '''パラメーター''' | ||
+ | ::* '''obj-'''スナップショットを生成するオブジェクト。 | ||
+ | ::* '''cf--'''生成された画像のカラーフォーマット。 | ||
+ | ::* '''dsc--'''画像の結果を保存する画像記述子。 | ||
+ | ::* '''buff--'''画像データを保存するためのバッファ。 | ||
+ | ::* '''buff_size-指定'''されたバッファサイズ(バイト単位)。 | ||
+ | : '''戻り値''' | ||
+ | :: 成功した場合はLV_RES_OK、エラーの場合はLV_RES_INV。 | ||
|} | |} | ||
:[[App:Library:LVGL:docs:Others|戻る : Previous]] | :[[App:Library:LVGL:docs:Others|戻る : Previous]] |
2022年6月29日 (水) 10:46時点における最新版
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. |
スナップショットは、LVGLオブジェクトのスナップショットイメージをその子と一緒に取得するためのAPIを提供します。
画像はオブジェクトとまったく同じように見えます。 |
Usage
英文 | 自動翻訳 |
---|---|
Simply call API Note, only below color formats are supported for now:
|
現在、以下のカラーフォーマットのみがサポートされていることに注意してください。
|
Free the Image
英文 | 自動翻訳 |
---|---|
The memory Use API 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 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);
}
|
メモリ API これにより、最初に画像データが使用するメモリが解放され、次に画像記述子が解放されます。
ただし、イメージオブジェクトは削除しないでください。 メモリを解放する前に、必ず 以下のコードスニペットは、このAPIの使用法を説明しています。 void update_snapshot (lv_obj_t * obj 、 lv_obj_t * img_snapshot )
{
lv_img_dsc_t * スナップショット = (void * )lv_img_get_src (img_snapshot )
if (snapshot ) {
lv_snapshot_free (snapshot )
}
スナップショット = lv_snapshot_take (obj 、 LV_IMG_CF_TRUE_COLOR_ALPHA )
lv_img_set_src (img_snapshot 、 snapshot);
}
|
Use Existing Buffer
英文 | 自動翻訳 |
---|---|
If the snapshot needs update now and then, or simply caller provides memory, use API
If snapshot is generated successfully, the image descriptor is updated and image data will be stored to provided
It's recommended to use API |
スナップショットを時々更新する必要がある場合、または単に呼び出し元がメモリを提供する場合は、この場合はAPIlv_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); を使用してください。
スナップショットが正常に生成されると、イメージ記述子が更新され、イメージデータが提供された
これは、オブジェクトサイズが変更されたときに発生する可能性があります。 API |
Example
Simple snapshot example
英文 | 自動翻訳 |
---|---|
API
英文 | 自動翻訳 |
---|---|
Functions *lv_snapshot_take( *obj, cf)
void lv_snapshot_free( *dsc)
uint32_t lv_snapshot_buf_size_needed( *obj, cf)
lv_res_t lv_snapshot_take_to_buf( *obj, cf, *dsc, void *buf, uint32_t buff_size)
|
lv_img_dsc_t * lv_snapshot_take( lv_obj_t * obj、 lv_img_cf_t cf)
void lv_snapshot_free(lv_img_dsc_t * dsc)
uint32_t lv_snapshot_buf_size_needed(lv_obj_t * obj、lv_img_cf_t cf)
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)
|