PNG image is not displaying

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • PNG image is not displaying

      Hi guys,

      I am using the Emwin version v6.16

      I need to show the image in the PNG format using the GUI_PNG_DrawEx() function. but the image is not displayed on the Window.

      1. PNG image file converted to C file using Bin2C convertor.
      2. Pass the array to GUI_PNG_DrawEx().

      Note: Same I have tried for BMP format images. BMP images are shown correctly.
      In my main application, I want to show a PNG image array stored in External Flash.

      Please help me out with this. If I missing something.
      I am attaching the source code files.

    • Hi Amol,

      Your implementation of the GetData() function is incorrect. That function is normally used for reading a file into the buffer pointed to by ppData. So in this case you would still have to copy the PNG data into the buffer, not just set the pointer. Below is a working implementation for reading the file from a C array:

      C Source Code

      1. /*********************************************************************
      2. *
      3. * _GetData
      4. */
      5. int _GetData(void* p, const U8** ppData, unsigned NumBytesReq, U32 Off) {
      6. char* pFileData;
      7. pFileData = (char*)p;
      8. memcpy((void *)*ppData, pFileData + Off, NumBytesReq);
      9. return NumBytesReq;
      10. }
      But as said, this function interface is mainly for reading the PNG from a file system. If you have the converted PNG file as a C array, you can use GUI_PNG_Draw() instead, which doesn't require a GetData() function.

      Best regards,
      Please read the forum rules before posting.

      Keep in mind, this is *not* a support forum.
      Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
      Should you be entitled to support you can contact us via our support system:

      Or you can contact us via e-mail.
    • Thanks, Florian,

      In EmwinSimulor over the Windows system, it is working fine. PNG images are showing properly.

      But in my actual application, I have added the EmwinPNG library from this link

      After adding the library it is compiled in KDS. The MCU is K22FN512 and External Flash is non-memory mapped.
      Allocated memory for emwin : static uint32_t s_gui_memory[(8000 + 3) / 4]; /* needs to be word-aligned */

      void LCD_X_Config(void)
      GUI_DEVICE *pDevice;
      CONFIG_FLEXCOLOR Config = {0, 0, GUI_MIRROR_X | GUI_MIRROR_Y, 0, 1};

      pDevice = GUI_DEVICE_CreateAndLink(GUIDRV_FLEXCOLOR, GUICC_M565, 0, 0);
      GUIDRV_FlexColor_Config(pDevice, &Config);

      LCD_SetSizeEx(0, LCD_WIDTH, LCD_HEIGHT);

      PortAPI.pfWrite16_A0 = LLD_LCD_HW.LCDHW_SendCmdWord ;
      PortAPI.pfWrite16_A1 = LLD_LCD_HW.LCDHW_SendDataWord;
      PortAPI.pfWriteM16_A1 = LLD_LCD_HW.LCDHW_SendMulDataWord;
      PortAPI.pfRead16_A1 = LLD_LCD_HW.LCDHW_ReadDataWord;
      PortAPI.pfReadM16_A1 = LLD_LCD_HW.LCDHW_ReadMulDataWord;

      GUIDRV_FlexColor_SetFunc(pDevice, &PortAPI, GUIDRV_FLEXCOLOR_F66720, GUIDRV_FLEXCOLOR_M16C0B16);

      The display interface is serial and the Driver is "lcdhw_ssd1963_16b"

      But PNG images are not Displaying its show blank.

      I have converted the PNG image directly to a C file using Bin2C.exe
      Please let me know if I am missing something.

      Thanks and Regards,
    • Hello,

      if there may still not be enough memory for the emWin memory pool? If we look in the user manual PNG library requires 21 Kb RAM + additional RAM depending on the image size. Your pool size is ~8 Kb as you put it.