JPEG into Memdev

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

  • JPEG into Memdev

    Hi,
    I am using 32F429I-Discovery Board with STemWin v5.32 and I am not able to show a JPEG image when I load it into a Memory Device.
    The code I am using is attached to the question.
    There firstly I draw the image at position (0,0) without problems, then I try to load it into a Memory Device and draw the it with some lines.
    I can see the lines but not the image, what can I do to draw the image?
    It is not a lack of memory because I have included some variables to know the free memory and the used memory after draw the image, after create the memdev and after delete de memdev and I can see that there is enough memory.

    Another question is about memory use, because when I get the free and the used memory after each use there is not the same amount of memory:
    [img]https://community.st.com/servlet/JiveServlet/downloadImage/2-152630-16416/Memory+use.png[/img]

    The variables a,c and d are refered to the free bytes and the others to the used bytes, so what I see is that if I do a+b, c+d and e+f, it should be the same value, but it is not.

    a+b=0x001DAB84
    c+d=0x001DAB64
    e+f=0x001DA3DC

    How it is possible?

    Thanks!
    Files
    • JPEG_MemDev.zip

      (3.78 kB, downloaded 330 times, last: )
  • Hi Roldi,

    Yes, at the first glance it looks like a memory leak. But everything is fine. Try to run the code in a while loop and you will see that no further memory gets "lost".

    When drawing a JPEG the memory management of emWin checks if enough memory blocks are available. If this isn't the case (the JPEG module requires a fair amount of blocks) emWin creates more memory blocks. After drawing the JPEG these blocks are not going to be deleted again. But, the memory used for these additional blocks is not lost and might be reused later in an application (e.g. next time you draw a JPEG).

    For the memory device it is almost the same. Depending on the memory device a larger block is required. When the memory device gets deleted the block stays the same size and the memory also seems to be lost. But same as above, the block might get reused later, too.

    Back to your initial questions.

    Try to call GUI_MEMDEV_Create() instead of GUI_MEMDEV_CreateFixed32(). The JPEG gets drawn with the color conversion of the LCD driver. If the LCD has a color depth 16 bpp and should get drawn into a memory device wiht 32 bpp it fails.

    We will change that in a future version of emWin to make sure it gets drawn with the color depth of currently selected device.

    Regards,
    Sven
    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: segger.com/ticket/

    Or you can contact us via e-mail.
  • Hello Sven,

    many thanks for your explanation about memory management, it is very helpful and really well explained.

    I have tried to use GUI_MEMDEV_Create() but I have the same result, I cannot see the jpeg within memdev.
    The LCD driver I am using is GUIDRV_LIN_32 so it should be ok for drawing the image with 32bpp, isn't it?

    Thanks!
  • Hi,
    The LCD driver I am using is GUIDRV_LIN_32 so it should be ok for drawing the image with 32bpp, isn't it?
    Which color conversion are you using?

    For GUIDRV_Lin you should use GUICC_8888 or GUICCM8888I. Also take a look into your GUIConf.h if GUI_USE_ARGB is defined to 1 you should use GUICC_M8888I. If this is not defined or defined as 0 you should use GUICC_8888.

    If these parameters don't fit it might be possible that the alpha channel gets misinterpreted and the drawing won't be visible.

    Please check you configuration in GUIConf.h if,

    GUI_USE_ARGB is 1 use GUICC_M8888I

    if,

    GUI_USE_ARGB is 0 or not even defined use GUICC_8888

    With GUI_USE_ARGB set 1 the color channels look like this

    ARGB where an alpha value of 0 means transparent and 255 is fully opaque.

    With GUI_USE_ARGB set to 0 or if it is not defined it looks like this

    ABGR where an alpha value of 0 means fully opaque and 255 transparent.

    Unfortunately, if you use a precompiled library, you won't be able to change GUI_USE_ARGB.

    Regards,
    Sven
    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: segger.com/ticket/

    Or you can contact us via e-mail.