硬汉嵌入式论坛

 找回密码
 立即注册
查看: 5174|回复: 2
收起左侧

[ThreadX全家桶] ThreadX GUIX加载JPEG图片,并将其绘制到内存设备方法

[复制链接]

1万

主题

7万

回帖

11万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
115804
QQ
发表于 2020-12-15 16:02:09 | 显示全部楼层 |阅读模式


代码:

  1. /******************************************************************************************/
  2. /* Decode main screen background jpeg.                                                    */
  3. /* The background jpeg is saved in the resource data in "raw" format, meaning it is still */
  4. /* a jpeg encoded graphic image. We need to decode and color space convert the raw jpeg   */
  5. /* data to create a GUIX pixelmap before we can draw the image.                           */
  6. /******************************************************************************************/
  7. static VOID decode_main_screen_jpeg()
  8. {
  9.     GX_IMAGE_READER reader;
  10.     GX_PIXELMAP *map;

  11.     /* get a pointer to the raw jpeg data */
  12.     gx_context_pixelmap_get(GX_PIXELMAP_ID_HOME_BG, &map);

  13.     /* create an image reader object */
  14.     gx_image_reader_create(&reader, map->gx_pixelmap_data, map->gx_pixelmap_data_size, GX_COLOR_FORMAT_24XRGB, 0);

  15.     /* decode and color space convert the jpeg to produce a GUIX compatible pixelmap image */
  16.     gx_image_reader_start(&reader, &main_screen_bg);
  17. }

  18. /******************************************************************************************/
  19. /* Override the default draw function of "main_screen".                                   */
  20. /******************************************************************************************/
  21. VOID main_screen_draw(GX_WINDOW *window)
  22. {
  23.     gx_window_background_draw(window);

  24.     /* If this is the first time drawing, then we need to decompress the raw jpeg
  25.        image we use to paint the screen background
  26.     */
  27.     if (!main_screen_bg.gx_pixelmap_data)
  28.     {
  29.         decode_main_screen_jpeg();
  30.     }

  31.     /* unless something went wrong, the pixelmap data should now be populated in
  32.        GUIX pixelmap format
  33.     */
  34.     if (main_screen_bg.gx_pixelmap_data)
  35.     {
  36.         /* Draw background map. */
  37.         gx_canvas_pixelmap_draw(window->gx_widget_size.gx_rectangle_left,
  38.             window->gx_widget_size.gx_rectangle_top, &main_screen_bg);
  39.     }
  40.     gx_widget_children_draw(window);
  41. }
复制代码


回复

使用道具 举报

681

主题

3487

回帖

5555

积分

论坛元老

积分
5555
发表于 2020-12-15 16:29:38 | 显示全部楼层
回复

使用道具 举报

6

主题

680

回帖

698

积分

金牌会员

积分
698
QQ
发表于 2020-12-15 17:12:16 | 显示全部楼层
虽然暂时用不上,但是还是要mark下的
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|Archiver|手机版|硬汉嵌入式论坛

GMT+8, 2025-5-19 18:30 , Processed in 0.250640 second(s), 24 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表