欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 5421|回復: 4
收起左側

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

[復制鏈接]
ID:316073 發表于 2018-11-26 21:21 | 顯示全部樓層 |閱讀模式
ILI9486TFT驅動程序STM32  這個用來移植

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

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

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


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

  3. /****************************************************************************************************************************
  4. *函數名稱:JpgDecoderRead()
  5. *參數    :
  6. *返回值  :
  7. *功能描述:用于JPG解碼讀取內存卡JPG文件數據,內部調用
  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. *函數名稱:Jpg_Display()
  29. *參數    :
  30. *返回值  :
  31. *功能描述:用于JPG解碼后將RGB數據顯示到TFT液晶屏,內部調用
  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.         /*將解碼數據顯示到液晶屏區域*/
  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.         /*設置水平方向X開始坐標*/

  70. //     LCD_WriteReg(0x50, rect->left);
  71. //   /*設置水平方向X結束坐標*/
  72. //   LCD_WriteReg(0x51, rect->right);
  73. //   /*設置豎直方向Y開始坐標*/
  74. //     LCD_WriteReg(0x52, rect->top);
  75. //   /*設置豎直方向Y結束坐標*/
  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. *函數名稱:Load_Jpg()
  91. *參數    :
  92. *返回值  :
  93. *功能描述:用于JPG解碼并顯示到TFT液晶屏,外部調用即可進行解碼顯示
  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數據 */
  105.         rc = jd_prepare(&jd, JpgDecoderRead, work, sz_work, fp);
  106.         if (rc == JDR_OK)
  107.         {

  108.                 /*判斷JPG的縮放,以適應屏幕大小*/
  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. }
復制代碼
  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.   * 函數名稱:main()
  11.   * 參數    :void
  12.   * 返回值  :void
  13.   * 描述    :程序主入口main函數
  14.   *************************************************************************************/
  15. int main(void)
  16. {
  17.           SystemInit();                                       //初始化系統時鐘,設置時鐘為168Mhz
  18.           LED_GPIO_Config();                                           //初始化LED的GPIO配置
  19.           SysTick_Init();                        //系統節拍初始化  
  20.           USART1_Conf();                         //串口1初始化
  21.           LCD_Init();                            //LCD初始化
  22.           printf("\r\n歡迎使用SY-STM32F407 V2開發板!\r\n");
  23.           printf("\r\n        山巖科技!\r\n");
  24.           printf("\r\n            -----專業,值得信賴!\r\n");
  25.           delay_nms(50);                          //延時
  26.           printf("\r\n 這是一個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

復制代碼


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



回復

使用道具 舉報

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

使用道具 舉報

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

使用道具 舉報

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

使用道具 舉報

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

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規則

小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術交流QQ群281945664

Powered by 單片機教程網

快速回復 返回頂部 返回列表