Several examples run on only mbed-os5.13.0 (not 5.14.0)
Dependencies: BD_SD_DISCO_F769NI BSP_DISCO_F769NI LCD_DISCO_F769NI TS_DISCO_F769NI USBHost_F769NI
Diff: zz_common/drawImage_copy1.cpp
- Revision:
- 4:0f4affc00183
- Parent:
- 3:35ac9ee7d2d6
--- a/zz_common/drawImage_copy1.cpp Wed Aug 07 05:39:01 2019 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,146 +0,0 @@ -/* - * Mbed function - * - * Created: July 30th, 2019 - * Revised: July 30th, 2019 - */ - -/* - https://os.mbed.com/users/Lightsource/code/DISCO-F746NG_BMP_FROM_SDCARD/ - https://www.gimp.org/downloads/ - https://os.mbed.com/questions/69098/how-can-I-load-an-image-to-screen/#answer14107 - */ - -//#include "select_program.h" -#if defined(NIOI_SENSOR) || defined(EXAMPLE_10_BITMAP) - -// Include -------------------------------------------------------------------- -#include "mbed.h" -#include "FATFileSystem.h" -#include "LCD_DISCO_F769NI.h" -#include "stm32f769i_discovery_lcd.h" - -// Definition ----------------------------------------------------------------- - -// Constructor ---------------------------------------------------------------- -extern Serial pc; -extern FATFileSystem fs; -extern LCD_DISCO_F769NI lcd; - -// RAM ------------------------------------------------------------------------ - -// ROM / Constant data -------------------------------------------------------- - -// Function prototypes -------------------------------------------------------- -//extern void drawImage(const char * name, uint16_t x, uint16_t y); -//extern void draw_bitmap(uint8_t *Name_BMP, uint32_t Xpos, uint32_t Ypos); - - -//------------------------------------------------------------------------------ -// Control Program -//------------------------------------------------------------------------------ -#if 0 -void draw_bitmap(uint8_t *Name_BMP, uint32_t Xpos, uint32_t Ypos) -{ - 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 *) (buffer + 10); - index |= (*(__IO uint16_t *) (buffer + 12)) << 16; - - /* Read bitmap width */ - width = *(uint16_t *) (buffer + 18); - width |= (*(uint16_t *) (buffer + 20)) << 16; - - /* Read bitmap height */ - height = *(uint16_t *) (buffer + 22); - height |= (*(uint16_t *) (buffer + 24)) << 16; - - /* Read bit/pixel */ - bit_pixel = *(uint16_t *) (buffer + 28); - - /* Set the address */ - //address = hLtdcHandler.LayerCfg[ActiveLayer].FBStartAdress + (((BSP_LCD_GetXSize()*Ypos) + Xpos)*(4)); - address = hltdc_discovery.LayerCfg[ActiveLayer].FBStartAdress + (((BSP_LCD_GetXSize()*Ypos) + Xpos)*(4)); - - /* Get the layer pixel format */ - if ((bit_pixel/8) == 4) { - input_color_mode = CM_ARGB8888; - } else if ((bit_pixel/8) == 2) { - input_color_mode = CM_RGB565; - } else { - input_color_mode = CM_RGB888; - } - - /* Bypass the bitmap header */ - 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 *)buffer, (uint32_t *)address, width, input_color_mode); - - /* Increment the source and destination buffers */ - address+= (BSP_LCD_GetXSize()*4); - buffer -= width*(bit_pixel/8); - } - free (buffer); -} -#endif -#if 1 -void drawImage(const char * name, uint16_t x, uint16_t y) -{ - int fileSize; - char * buffer; - - FILE *image = fopen(name, "rb"); // open the bmp file - if (image == 0) { - pc.printf("%s is not found in the disk\r\n", name); - return; - } - //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); - // copy the file into the buffer: - fseek (image, 0, SEEK_SET ); - // set SD file data start position - fread (buffer,1,fileSize,image); - fclose (image); - - //Draw image - lcd.DrawBitmap(x,y,(uint8_t *)buffer); - //Free allocated memory - free (buffer); -} -#endif -#endif