[应用相关] [stm32] 利用uC-BmpCvt软件生成uc-gui可调用的bmp图片

[复制链接]
532|2
 楼主| deadtime 发表于 2020-1-1 16:52 | 显示全部楼层 |阅读模式
>_<:学习贴图[bmp图]:首先找一张bmp格式的图片,然后下载uC-BmpCvt软件,打开改图片
191939418401471.jpg
>_<:然后点击Image-Conver-Into-Best Palatte调成最佳调色板,然后save格式为默认格式:
191941583566743.jpg

 楼主| deadtime 发表于 2020-1-1 16:52 | 显示全部楼层
>_<:结果生成了一个kk.c文件:

这里Colorskk[]是16个颜色;
Palkk是根据上面的16个颜色构建对应的调色板;
ackk[]为Bmp图的内容;
bmkk为根据上面的调色板,bmp内容建立uc-gui的函数可以调用的图片格式,在Fun函数里用函数GUI_DrawBitmap(&bmkk,0,0);就能把这幅图贴在(0,0)位置啦!
 楼主| deadtime 发表于 2020-1-1 16:53 | 显示全部楼层
  1. #include "stdlib.h"

  2. #include "GUI.H"

  3. /*   Palette
  4. The following are the entries of the palette table.
  5. Every entry is a 32-bit value (of which 24 bits are actually used)
  6. the lower   8 bits represent the Red component,
  7. the middle  8 bits represent the Green component,
  8. the highest 8 bits (of the 24 bits used) represent the Blue component
  9. as follows:   0xBBGGRR
  10. */

  11. const GUI_COLOR Colorskk[] = {
  12.      0xFFFFFF,0x000000,0xC0C0C0,0x808080
  13.     ,0x00FFFF,0xFF0000,0x008080,0x800000
  14.     ,0x0000FF,0x000080,0xFFFF00,0x808000
  15.     ,0x008000,0x800080,0xFF00FF,0x00FF00
  16. };

  17. const GUI_LOGPALETTE Palkk = {
  18.   16,    /* number of entries */
  19.   0,     /* No transparency */
  20.   &Colorskk[0]
  21. };

  22. const unsigned char ackk[] = {...};
  23. const GUI_BITMAP bmkk = {
  24. 798, /* XSize */
  25. 480, /* YSize */
  26. 399, /* BytesPerLine */
  27. 4, /* BitsPerPixel */
  28. ackk,  /* Pointer to picture data (indices) */
  29. &Palkk  /* Pointer to palette */
  30. };
您需要登录后才可以回帖 登录 | 注册

本版积分规则

44

主题

470

帖子

2

粉丝
快速回复 在线客服 返回列表 返回顶部