>_<:學習貼圖[bmp圖]:首先找一張bmp格式的圖片,然后下載uC-BmpCvt軟件,打開改圖片
>_<:然后點擊Image-Conver-Into-Best Palatte調成最佳調色板,然后save格式為默認格式:
>_<:結果生成了一個kk.c文件:
- 這里Colorskk[]是16個顏色;
- Palkk是根據上面的16個顏色構建對應的調色板;
- ackk[]為Bmp圖的內容;
- bmkk為根據上面的調色板,bmp內容建立uc-gui的函數可以調用的圖片格式,在Fun函數里用函數GUI_DrawBitmap(&bmkk,0,0);就能把這幅圖貼在(0,0)位置啦!
1 #include "stdlib.h" 2 3 #include "GUI.H" 4 5 /* Palette 6 The following are the entries of the palette table. 7 Every entry is a 32-bit value (of which 24 bits are actually used) 8 the lower 8 bits represent the Red component, 9 the middle 8 bits represent the Green component, 10 the highest 8 bits (of the 24 bits used) represent the Blue component 11 as follows: 0xBBGGRR 12 */ 13 14 const GUI_COLOR Colorskk[] = { 15 0xFFFFFF,0x000000,0xC0C0C0,0x808080 16 ,0x00FFFF,0xFF0000,0x008080,0x800000 17 ,0x0000FF,0x000080,0xFFFF00,0x808000 18 ,0x008000,0x800080,0xFF00FF,0x00FF00 19 }; 20 21 const GUI_LOGPALETTE Palkk = { 22 16, /* number of entries */ 23 0, /* No transparency */ 24 &Colorskk[0] 25 }; 26 27 const unsigned char ackk[] = {...}; 28 const GUI_BITMAP bmkk = { 29 798, /* XSize */ 30 480, /* YSize */ 31 399, /* BytesPerLine */ 32 4, /* BitsPerPixel */ 33 ackk, /* Pointer to picture data (indices) */ 34 &Palkk /* Pointer to palette */ 35 };