久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费

 找回密碼
 立即注冊(cè)

QQ登錄

只需一步,快速開始

搜索
查看: 5303|回復(fù): 4
收起左側(cè)

STM32+ILI9486 TFT JPEG圖片解碼例程下載

[復(fù)制鏈接]
ID:316073 發(fā)表于 2018-11-26 21:21 | 顯示全部樓層 |閱讀模式
ILI9486TFT驅(qū)動(dòng)程序STM32  這個(gè)用來移植

1、該例程為JPEG圖片解碼例程。

2、使用說明
   (1)工程文件路徑:SY-STM32F407 V2程序\SY-STM32F407 V2例程:JPEG圖片解碼例程\Project\Project.uvproj。
   (2)請(qǐng)使用MDK 4.0以上版本打開,MDK版本過低會(huì)導(dǎo)致無法識(shí)別工程。
   (3)下載調(diào)試工具為JLINK。
   (4)請(qǐng)將串口線(直連串口線)插在板子COM1口上,并打開超級(jí)終端或串口助手,配置波特率115200,8位,一個(gè)停止位,無校驗(yàn)位。
   (5)HEX文件下載到板子后,使用超級(jí)終端或串口調(diào)試助手可以看到調(diào)試信息,插上TFT模塊顯示一個(gè)小MM,表明例程運(yùn)行正確。
3、注意事項(xiàng)
   請(qǐng)務(wù)必在下載、調(diào)試、運(yùn)行過程中,保持板子上電、JLINK連接并插在電腦上。

單片機(jī)源程序如下:
  1. #include "jpegdecoder.h"


  2. static int MaskT, MaskL, MaskR, MaskB;        /* Active drawing area */

  3. /****************************************************************************************************************************
  4. *函數(shù)名稱:JpgDecoderRead()
  5. *參數(shù)    :
  6. *返回值  :
  7. *功能描述:用于JPG解碼讀取內(nèi)存卡JPG文件數(shù)據(jù),內(nèi)部調(diào)用
  8. ******************************************************************************************************************************/
  9. static UINT JpgDecoderRead(JDEC* jd,                /* Decoder object */BYTE* buff,                /* Pointer to the read buffer (NULL:skip) */UINT nd                        /* Number of bytes to read/skip from input stream */)
  10. {
  11.         UINT rb;
  12.         FIL *fil = (FIL*)jd->device;        /* Input stream of this session */


  13.         if (buff) {        /* Read nd bytes from the input strem */
  14.                 f_read(fil, buff, nd, &rb);
  15.                 return rb;        /* Returns number of bytes could be read */

  16.         } else {        /* Skip nd bytes on the input stream */
  17.                 return (f_lseek(fil, f_tell(fil) + nd) == FR_OK) ? nd : 0;
  18.         }
  19. }
  20. void SetJPGDisplayAera(uint16_t xs,uint16_t ys,uint16_t xe,uint16_t ye)
  21. {
  22.                 MaskL = xs;
  23.                 MaskR = xe;
  24.                 MaskT = ys;
  25.                 MaskB = ye;
  26. }
  27. /****************************************************************************************************************************
  28. *函數(shù)名稱:Jpg_Display()
  29. *參數(shù)    :
  30. *返回值  :
  31. *功能描述:用于JPG解碼后將RGB數(shù)據(jù)顯示到TFT液晶屏,內(nèi)部調(diào)用
  32. ******************************************************************************************************************************/
  33. static UINT Jpg_Display (
  34.         JDEC* jd,                /* Decoder object */
  35.         void* bitmap,        /* Bitmap data to be output */
  36.         JRECT* rect                /* Rectangular region to output */
  37. )
  38. {
  39.                 int yc, xc, xl, xs;
  40.          uint16_t *pData=(uint16_t*)bitmap;
  41.         jd = jd;        /* Suppress warning (device identifier is not needed) */

  42.         /*將解碼數(shù)據(jù)顯示到液晶屏區(qū)域*/
  43.         //disp_blt(rect->left, rect->right, rect->top, rect->bottom, (uint16_t*)bitmap);
  44.        


  45.         if (rect->left > rect->right || rect->top > rect->bottom) return 0;         /* Check varidity */
  46.         if (rect->left > MaskR || rect->right < MaskL  || rect->top > MaskB || rect->bottom < MaskT) return 0;        /* Check if in active area */

  47.         yc = rect->bottom - rect->top + 1;                        /* Vertical size */
  48.         xc = rect->right - rect->left + 1; xs = 0;        /* Horizontal size and skip */

  49.         if (rect->top < MaskT) {                /* Clip top of source image if it is out of active area */
  50.                 pData += xc * (MaskT - rect->top);
  51.                 yc -= MaskT - rect->top;
  52.                 rect->top = MaskT;
  53.         }
  54.         if (rect->bottom > MaskB) {        /* Clip bottom of source image if it is out of active area */
  55.                 yc -= rect->bottom - MaskB;
  56.                 rect->bottom = MaskB;
  57.         }
  58.         if (rect->left < MaskL) {                /* Clip left of source image if it is out of active area */
  59.                 pData += MaskL - rect->left;
  60.                 xc -= MaskL - rect->left;
  61.                 xs += MaskL - rect->left;
  62.                 rect->left = MaskL;
  63.         }
  64.         if (rect->right > MaskR) {        /* Clip right of source image it is out of active area */
  65.                 xc -= rect->right - MaskR;
  66.                 xs += rect->right - MaskR;
  67.                 rect->right = MaskR;
  68.         }
  69.         /*設(shè)置水平方向X開始坐標(biāo)*/

  70. //     LCD_WriteReg(0x50, rect->left);
  71. //   /*設(shè)置水平方向X結(jié)束坐標(biāo)*/
  72. //   LCD_WriteReg(0x51, rect->right);
  73. //   /*設(shè)置豎直方向Y開始坐標(biāo)*/
  74. //     LCD_WriteReg(0x52, rect->top);
  75. //   /*設(shè)置豎直方向Y結(jié)束坐標(biāo)*/
  76. //   LCD_WriteReg(0x53, rect->bottom);
  77.   LCD_SetCursor(rect->left, rect->top);
  78.         LCD_WriteRAM_Start();
  79.         do {        /* Send image data */
  80.                 xl = xc;
  81.                 do {
  82.                         //pd = *pat++;
  83.                         LCD_WriteRAM(*pData++);                        //顯示像素
  84.                 } while (--xl);
  85.                 pData += xs;
  86.         } while (--yc);
  87.         return 1;        /* Continue decompression */       
  88. }
  89. /****************************************************************************************************************************
  90. *函數(shù)名稱:Load_Jpg()
  91. *參數(shù)    :
  92. *返回值  :
  93. *功能描述:用于JPG解碼并顯示到TFT液晶屏,外部調(diào)用即可進(jìn)行解碼顯示
  94. ******************************************************************************************************************************/
  95. void Load_Jpg (
  96.         FIL *fp,                /* Pointer to the open file object to load */
  97.         void *work,                /* Pointer to the working buffer (must be 4-byte aligned) */
  98.         UINT sz_work        /* Size of the working buffer (must be power of 2) */
  99. )
  100. {
  101.         JDEC jd;                /* Decoder object (124 bytes) */
  102.         JRESULT rc;
  103.         BYTE scale;

  104.         /*載入需要解碼的JPG數(shù)據(jù) */
  105.         rc = jd_prepare(&jd, JpgDecoderRead, work, sz_work, fp);
  106.         if (rc == JDR_OK)
  107.         {

  108.                 /*判斷JPG的縮放,以適應(yīng)屏幕大小*/
  109.                 for (scale = 0; scale < 3; scale++)
  110.                 {
  111.                         if ((jd.width >> scale) <= LCD_XMAX && (jd.height >> scale) <= LCD_YMAX) break;
  112.                 }

  113.                 /* 開始解碼JPG文件并顯示到液晶屏 */
  114.                 rc = jd_decomp(&jd, Jpg_Display, scale);        /* Start to decompress */

  115.         } else {
  116.                 LCD_SetColors(RED,WHITE);
  117.     LCD_DrawString(30,140,"prepare ERR");
  118.         }
  119. }
復(fù)制代碼
  1. /* ------------------------------------------包含的頭文件-----------------------------------------------*/
  2. #include "stm32f4xx.h"
  3. #include "delay.h"
  4. #include "led.h"
  5. #include "usart.h"
  6. #include "lcd.h"
  7. #include "adc.h"


  8. extern unsigned  char JPGBUFF[];


  9. /*************************************************************************************
  10.   * 函數(shù)名稱:main()
  11.   * 參數(shù)    :void
  12.   * 返回值  :void
  13.   * 描述    :程序主入口main函數(shù)
  14.   *************************************************************************************/
  15. int main(void)
  16. {
  17.           SystemInit();                                       //初始化系統(tǒng)時(shí)鐘,設(shè)置時(shí)鐘為168Mhz
  18.           LED_GPIO_Config();                                           //初始化LED的GPIO配置
  19.           SysTick_Init();                        //系統(tǒng)節(jié)拍初始化  
  20.           USART1_Conf();                         //串口1初始化
  21.           LCD_Init();                            //LCD初始化
  22.           printf("\r\n歡迎使用SY-STM32F407 V2開發(fā)板!\r\n");
  23.           printf("\r\n        山巖科技!\r\n");
  24.           printf("\r\n            -----專業(yè),值得信賴!\r\n");
  25.           delay_nms(50);                          //延時(shí)
  26.           printf("\r\n 這是一個(gè)JPG解碼例程 \r\n");

  27.           LoadJpegFile(JPGBUFF);

  28.         while(1)
  29.         {
  30.                   LED1(On);
  31.                 delay_nms(300);
  32.                 LED1(Off);
  33.                 delay_nms(300);               
  34.         }
  35. }


  36. #ifdef  USE_FULL_ASSERT

  37. /**
  38.   * @brief  Reports the name of the source file and the source line number
  39.   *   where the assert_param error has occurred.
  40.   * @param  file: pointer to the source file name
  41.   * @param  line: assert_param error line source number
  42.   * @retval None
  43.   */
  44. void assert_failed(uint8_t* file, uint32_t line)
  45. {
  46.   /* User can add his own implementation to report the file name and line number,
  47.      ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */

  48.   /* Infinite loop */
  49.   while (1)
  50.   {
  51.   }
  52. }
  53. #endif

復(fù)制代碼


所有資料51hei提供下載:
ILI9486 JPEG圖片解碼例程.rar (491.05 KB, 下載次數(shù): 95)



回復(fù)

使用道具 舉報(bào)

ID:365013 發(fā)表于 2018-12-28 09:07 | 顯示全部樓層
好東西
回復(fù)

使用道具 舉報(bào)

ID:476086 發(fā)表于 2019-2-13 10:45 | 顯示全部樓層
這里解碼和壓縮的原理是什么,能不能解釋下?
回復(fù)

使用道具 舉報(bào)

ID:647790 發(fā)表于 2019-11-23 13:02 | 顯示全部樓層
參考一下代碼,準(zhǔn)備移植感謝樓主分享
回復(fù)

使用道具 舉報(bào)

ID:503899 發(fā)表于 2022-8-28 01:47 | 顯示全部樓層
圖片文件是用什么工具產(chǎn)生的?
回復(fù)

使用道具 舉報(bào)

本版積分規(guī)則

手機(jī)版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表
主站蜘蛛池模板: 国产日韩一区二区 | 成人黄色在线观看 | 亚洲精品91 | 1级毛片| 亚洲午夜精品久久久久久app | 九九热这里 | 久久91精品国产一区二区 | 国产日韩欧美中文 | 在线观看免费观看在线91 | 99精品国产一区二区三区 | 国产一区精品 | 日韩精品无码一区二区三区 | 日韩欧美中文字幕在线观看 | 国产超碰人人爽人人做人人爱 | 亚洲永久免费观看 | 91成人在线视频 | 国产农村妇女精品一二区 | 久久小视频 | 精品国产视频 | 国产精品美女久久久久aⅴ国产馆 | 欧美成年人| 亚洲精品国产电影 | 91久久久久久| 日韩视频在线免费观看 | 日韩综合在线 | 久久免费视频2 | 国产传媒在线播放 | 欧美一区二区大片 | 伊人手机在线视频 | 视频一区在线观看 | av在线一区二区三区 | 欧美精品在线观看 | www.天天操.com | 久久激情网 | 日韩久久久久久 | 欧美一级片在线观看 | 黄瓜av | 中文字幕不卡在线88 | 天天天久久久 | 欧美淫 | 国产一区二区麻豆 |