.

Fork of BSP_DISCO_F746NG by ST

Files at this revision

API Documentation at this revision

Comitter:
shoaib_ahmed
Date:
Mon Jul 31 09:50:10 2017 +0000
Parent:
2:458ab1edf6b2
Commit message:
.

Changed in this revision

stm32746g_discovery_lcd.c Show annotated file Show diff for this revision Revisions of this file
diff -r 458ab1edf6b2 -r 65aafc10c66e stm32746g_discovery_lcd.c
--- a/stm32746g_discovery_lcd.c	Thu Mar 24 20:50:59 2016 +0000
+++ b/stm32746g_discovery_lcd.c	Mon Jul 31 09:50:10 2017 +0000
@@ -921,26 +921,52 @@
   * @param  pbmp: Pointer to Bmp picture address in the internal Flash
   * @retval None
   */
-void BSP_LCD_DrawBitmap(uint32_t Xpos, uint32_t Ypos, uint8_t *pbmp)
+ 
+void BSP_LCD_DrawBitmap(uint32_t Xpos, uint32_t Ypos, uint8_t *Name_BMP)
 {
+  #include <stdlib.h>
   uint32_t index = 0, width = 0, height = 0, bit_pixel = 0;
   uint32_t address;
   uint32_t input_color_mode = 0;
+  char filename[50];
+  int i, fileSize;
+  char * buffer;
+   
+  i=0;
+    while (*Name_BMP!='\0') {
+        filename[i++]=*Name_BMP++;
+    }  
+   
+  filename[i] = 0; 
+    FILE *Image = fopen((const char *)&filename[0], "rb");  // open the bmp file
+  
+   // obtain file size:
+    fseek (Image , 0 , SEEK_END);
+    fileSize = ftell (Image);
+    rewind (Image);
+    
+    // allocate memory to contain the whole file:
+    buffer = (char*) malloc (sizeof(char)*fileSize/2);
+    
+    // copy the file into the buffer:
+    fseek (Image, 0 , SEEK_SET );  // set SD file data start position    
+    fread (buffer,1,fileSize,Image);
+    fclose (Image);
   
   /* Get bitmap data address offset */
-  index = *(__IO uint16_t *) (pbmp + 10);
-  index |= (*(__IO uint16_t *) (pbmp + 12)) << 16;
+  index = *(__IO uint16_t *) (buffer + 10);
+  index |= (*(__IO uint16_t *) (buffer + 12)) << 16;
   
   /* Read bitmap width */
-  width = *(uint16_t *) (pbmp + 18);
-  width |= (*(uint16_t *) (pbmp + 20)) << 16;
+  width = *(uint16_t *) (buffer + 18);
+  width |= (*(uint16_t *) (buffer + 20)) << 16;
   
   /* Read bitmap height */
-  height = *(uint16_t *) (pbmp + 22);
-  height |= (*(uint16_t *) (pbmp + 24)) << 16; 
+  height = *(uint16_t *) (buffer + 22);
+  height |= (*(uint16_t *) (buffer + 24)) << 16; 
   
   /* Read bit/pixel */
-  bit_pixel = *(uint16_t *) (pbmp + 28);   
+  bit_pixel = *(uint16_t *) (buffer + 28);   
   
   /* Set the address */
   address = hLtdcHandler.LayerCfg[ActiveLayer].FBStartAdress + (((BSP_LCD_GetXSize()*Ypos) + Xpos)*(4));
@@ -960,19 +986,21 @@
   }
   
   /* Bypass the bitmap header */
-  pbmp += (index + (width * (height - 1) * (bit_pixel/8)));  
+  buffer += (index + (width * (height - 1) * (bit_pixel/8)));  
   
   /* Convert picture to ARGB8888 pixel format */
   for(index=0; index < height; index++)
   {
     /* Pixel format conversion */
-    LL_ConvertLineToARGB8888((uint32_t *)pbmp, (uint32_t *)address, width, input_color_mode);
-    
+    LL_ConvertLineToARGB8888((uint32_t *)buffer, (uint32_t *)address, width, input_color_mode);
+ 
     /* Increment the source and destination buffers */
     address+=  (BSP_LCD_GetXSize()*4);
-    pbmp -= width*(bit_pixel/8);
-  } 
+    buffer -= width*(bit_pixel/8);
+  }
+  free (buffer); 
 }
+ 
 
 /**
   * @brief  Draws a full rectangle.