having problems displaying PNG image

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

  • having problems displaying PNG image

    I'm using the STM3220G-EVAL board with the emWin library STemWin522_CM3_OS_IAR.a. I downloaded the PNG library from segger.com/link/emwin_png.zip. That zip file contains folders named emWin_V4.18, emWin_V5.00, emWin_V5.18 and emWin_V5.26. I assumed since my library version is 5.22, the version emWin_5.18 is probably the one most suitable for use in my project so I unzipped that code and compiled/linked that version of the PNG software into my project. I am using the IAR Embedded Workbench for development. I am using emWinGUIBuilder V5.22 and with that utility I placed an Image on my window and assigned a PNG graphic to that Image.

    When I compile/link and then display this window I see that the PNG library is failing to display the image. Upon rendering the image the code stops execution here:

    static void _png_cexcept_error(png_structp png_ptr, png_const_charp msg) {
    GUI_USE_PARA(png_ptr);
    GUI_USE_PARA(msg);
    while (1); /* Stop on error */
    }

    The error indicated by msg is "zlib memory error".

    How do I resolve this issue?
  • Hello,

    The version numbers in the PNG library indicate with which emWin version the according files work. emWin version in this context means emWin version and later until the next newer version. So the emWin_V5.00 package works with all version between V5.00 and V5.16.

    I assume you will have to assign more memory to emWin.

    Best regards,
    Adrian
  • I did get it working with version 5.18 but I had to increase the memory assigned using GUI_ALLOC_AssignMemory() from 110KB to 240KB just to be able to decode a small ~50x50 PNG. Is it normal to require so much memory for decoding PNG images?
  • Hello !

    Yes, I have the same "problem". 50x50px works fine with 110k for the GUI. 190x190 does not work anymore... Not enough RAM.
    Section 8.4 says 21k RAM for decompression only AND additional RAM for the picture + overhead 54k !?
    If this is true I have to check where the rest has gone...

    Increasing RAM for the GUI decreases RAM for the rest of the program. I found some conflicts here. Program stopps or hangs after or while creating PNG drawing (picture is too large). So it does not work anymore.
    I will try to figure out what is really needed. There are some options to decrease the required RAM size. I do not want to use external in the first place. F429i discovery has external RAM, slower but working fine. SD card could probably also be used.
    I need PNG for transparency, because GIF is not an option.

    The static data of the PNG from GuiBuilder till 5.24 is stored in RAM, is that right? Making it const static like in 5.26 moves it to FLASH, keeping RAM free. Can you confirm this change?

    Best regards,
    HaJo
  • Hello HaJo,

    Yes, unfortunately PNG decompression requires a lot of RAM.

    Yes, const data would be stored in a read-only memory area. Please note that moving the PNG source data to another memory location would not affect the PNG memory requirement. Details can be found in the function GUI_X_Config() (GUIConf.c).

    Best regards,
    Adrian