Tuesday, May 22nd 2018, 3:35pm UTC+2

You are not logged in.

  • Login
  • Register

Dear visitor, welcome to SEGGER Forum. If this is your first visit here, please read the Help. It explains how this page works. You must be registered before you can use all the page's features. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

trial

Beginner

Date of registration: Apr 24th 2018

Posts: 6

1

Thursday, May 17th 2018, 9:40am

MAKE TRANSPARENT IMAGE BLINKING

Hello
i have an IMAGE widget containing a PNG file. I want to have this image with transparency and make it blink (sometimes we see the balckground trough this image, and sometime we only see the baclground)



1) I created the image in the frame with :
{ IMAGE_CreateIndirect, "DLC_not_active", ID_IMAGE_DLC_NO_ACTIVE_3, 13, 9, 241, 174, WM_CF_SHOW, IMAGE_CF_MEMDEV | IMAGE_CF_ALPHA, 0 },

2) i set png file to this widget :
case WM_INIT_DIALOG:

hItem = WM_GetDialogItem(hWin, ID_IMAGE_DLC_NO_ACTIVE_3);
WM_SetCallback(hItem, _cbDLC_not_active2);
IMAGE_SetPNG(hItem, &_acImage_DLC_not_active_transparent, sizeof(_acImage_DLC_not_active_transparent));

3) in the call back i call GUI_PNG_Draw :
case WM_PAINT:
GUI_EnableAlpha(1);
if (DLG_Load_menu_hide_show == 1)
GUI_PNG_Draw(&_acImage_DLC_not_active_transparent, sizeof(_acImage_DLC_not_active_transparent), 0, 0);
GUI_EnableAlpha(0);

4) on timer event i call WM_HideWindow/WM_ShowWin
if (DLG_Load_menu_hide_show == 0)
{
WM_HideWindow(hItem);
DLG_Load_menu_hide_show = 1;

}
else
{
WM_ShowWin(hItem);
DLG_Load_menu_hide_show = 0;
}


The problem is that i can't make the image blinking (make it disapear)
It seems that with a bitmap i don't have this problem (i don't need the call back and the blinking is OK)

A) How can i make the image disapear ?

B)It seems that the PNG image has contains transparency information to display it with transparency : can we diplay a non transparent PNG image in a IMAGE WIDGET with transparency ?


Thanks
best regards

SEGGER - Schoenen

Super Moderator

Date of registration: Aug 13th 2015

Posts: 584

2

Thursday, May 17th 2018, 2:26pm

Hi,

Attached is an example which shows three different ways of letting an image blink.

The first way is to create a dialog with an IMAGE widget and just hide/show the IMAGE widget each time a timer expires.

The second is more or less the same but without a dialog. The IMAGE widget gets created as child of the desktop window.

The third way is creating a simple window and manage drawing of the PNG in the callback.

Quoted

A) How can i make the image disapear ?
See above. I guess the easiest way is to hide/show the IMAGE widget. No need to overwrite a callback.

Quoted

B)It seems that the PNG image has contains transparency information to
display it with transparency : can we diplay a non transparent PNG image
in a IMAGE WIDGET with transparency ?
Of course, there is no difference in how the PNG gets displayed.

There is no need to use GUI_EnableAlpha(). You should try to avoid this because it can have a big impact on the performance.

Regards,
Sven

trial

Beginner

Date of registration: Apr 24th 2018

Posts: 6

3

Thursday, May 17th 2018, 2:57pm

thank you for your reply
i can't find the attached file