Hello all,
I wrote some code as follows:
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:
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.
I wrote some code as follows:
C Source Code
- static void _cbImageShtr(WM_MESSAGE * pMsg) {
- /* Local variable(s) */
- WM_HWIN hWin;
- uint8_t UserData[20];
- uint8_t * pData;
- int Index;
- int NumItems;
- int Period;
- size_t Offset;
- /* Handle the message(s) needed */
- switch (pMsg->MsgId) {
- case WM_TIMER:
- hWin = pMsg->hWin;
- if (IMAGE_GetUserData(hWin, UserData, sizeof(UserData))) {
- pData = UserData;
- Offset = sizeof(int);
- Period = *(int *)pData;
- pData += Offset;
- NumItems = *(int *)pData;
- pData += Offset;
- Index = *(int *)pData + 1;
- if (Index < NumItems) {
- *(int *)pData = Index;
- pData += Offset;
- IMAGE_SetBitmap(hWin, ((void **)*((intptr_t *)pData))[Index]);
- IMAGE_SetUserData(hWin, UserData, sizeof(UserData));
- WM_RestartTimer(pMsg->Data.v, Period);
- } else {
- WM_DeleteTimer(pMsg->Data.v);
- WM_HideWindow(hWin);
- WM_DeleteWindow(hWin);
- }
- }
- return;
- case WM_DELETE:
- _hImageShtr = WM_HMEM_NULL;
- WM_SendMessageNoPara(_hColorbar, UI_MSG_SCREEN_DUMP);
- break;
- }
- /* Default message handler */
- IMAGE_Callback(pMsg);
- }
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:
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.