Hello all,
I wrote some code as follows:
|
C/C++ Source code
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
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, t
hen 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/C++ Source code
|
1
2
|
WM_HideWindow(hWin);
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.