How to make sure an image is removed from screen?

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

  • How to make sure an image is removed from screen?

    Hello all,

    I wrote some code as follows:

    C Source Code

    1. static void _cbImageShtr(WM_MESSAGE * pMsg) {
    2. /* Local variable(s) */
    3. WM_HWIN hWin;
    4. uint8_t UserData[20];
    5. uint8_t * pData;
    6. int Index;
    7. int NumItems;
    8. int Period;
    9. size_t Offset;
    10. /* Handle the message(s) needed */
    11. switch (pMsg->MsgId) {
    12. case WM_TIMER:
    13. hWin = pMsg->hWin;
    14. if (IMAGE_GetUserData(hWin, UserData, sizeof(UserData))) {
    15. pData = UserData;
    16. Offset = sizeof(int);
    17. Period = *(int *)pData;
    18. pData += Offset;
    19. NumItems = *(int *)pData;
    20. pData += Offset;
    21. Index = *(int *)pData + 1;
    22. if (Index < NumItems) {
    23. *(int *)pData = Index;
    24. pData += Offset;
    25. IMAGE_SetBitmap(hWin, ((void **)*((intptr_t *)pData))[Index]);
    26. IMAGE_SetUserData(hWin, UserData, sizeof(UserData));
    27. WM_RestartTimer(pMsg->Data.v, Period);
    28. } else {
    29. WM_DeleteTimer(pMsg->Data.v);
    30. WM_HideWindow(hWin);
    31. WM_DeleteWindow(hWin);
    32. }
    33. }
    34. return;
    35. case WM_DELETE:
    36. _hImageShtr = WM_HMEM_NULL;
    37. WM_SendMessageNoPara(_hColorbar, UI_MSG_SCREEN_DUMP);
    38. break;
    39. }
    40. /* Default message handler */
    41. IMAGE_Callback(pMsg);
    42. }
    Display All


    It will display a serial of images, then tell emWin to get a screenshot.
    The problem is that, sometimes the last image showed in the screenshot.
    But, look into the code, this should not happen, right? For it's hidden then deleted:


    C Source Code

    1. WM_HideWindow(hWin);
    2. WM_DeleteWindow(hWin);



    So, the question is, how to make sure that an image is removed from screen?

    PS:
    I get a screenshot by copy the visible buffer of emWin, not using BMP_Serialize() for its speed.
  • Hi,

    In general I don't recommend to use GUI_Exec() within a callback function, but you can try to call GUI_Exec() right after WM_HideWindow().

    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.