Alpha Blending Windows

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

  • Alpha Blending Windows

    Hi,
    I have created popups using "Alpha blending". To achieve the popup effect, I am using two windows. One base window with transparency enabled and one window on top of that which has the required text. When the popup windows are deleted and a listbox screen is displayed then some portion of the screen is purple. I am setting the background color to be black. I have attached screenshots of both the scenarios.
    Image1: Is the popup window with transparency enabled for the base window
    Code is as follows
    GUI_SetAlpha(85); // Set alpha value for drawing operations
    GUI_SetBkColor(GUI_DARKGRAY); // Draw gray background...
    GUI_Clear(); // ...with alpha blending
    GUI_SetAlpha(0); // Set alpha value to default

    //for the border of the inner rectangle
    GUI_SetColor(GUI_YELLOW);
    GUI_FillRect((Child_window_x_pos-6), (Child_window_y_pos - 31),
    (Child_window_x_pos + Child_window_x_size), (Child_window_y_pos + Child_window_y_size - 26));

    Image2: Is the listbox screen.

    Why does this occur and how do I get rid of it?

    I have observed this issue, when I go from one popup to the other in succession. Before creating a new popup screen, I make sure to delete the previous windows.

    Thanks
    Images
    • Image1.png

      8.52 kB, 813×426, viewed 960 times
    • Image2.png

      13.6 kB, 810×426, viewed 991 times

    The post was edited 2 times, last by Ana ().

  • Hello,

    I am afraid I am not able to reproduce this. Please make sure that all drawing operations are performed within the callback function of the respective window. Further the desktop window should be configured to be drawn. This can be achieved by implementing a custom callback function or by calling the function WM_SetDesktopColor().

    Best regards,
    Adrian
  • Hi,
    I was able to resolve the issue. The popup windows were being drawn on top of each other without memory being deleted.
    Now on the actual hardware, the popup window is displayed very slowly. How can I make sure that it is displayed in one go?
    I have enabled multi-buffering as well.

    Thanks
  • Hi,
    No the other windows are created quite fast. The windows are drawn as follows:

    GUI_data.Window1 = WM_CreateWindow(WINDOW_POS_X, WINDOW_POS_Y, WINDOW_SIZE_X, WINDOW_SIZE_Y,
    WM_CF_SHOW, callback_standby_screen, 0);

    GUI_data.Window2 = WM_CreateWindow(Child_window_x_pos, Child_window_y_pos, Child_window_x_size, Child_window_y_size,
    WM_CF_SHOW, callback_standby_screen, 0);


    WM_SetHasTrans(GUI_data.Window1);


    The call back is as follows:
    if((pMsg->hWin) == GUI_data.Window1)
    {
    GUI_SetAlpha(85); // Set alpha value for drawing operations
    GUI_SetBkColor(GUI_DARKGRAY); // Draw gray background..
    GUI_Clear(); // ...with alpha blending
    GUI_SetAlpha(0); // Set alpha value to default
    //for the border of the inner rectangle
    GUI_SetColor(GUI_YELLOW);
    GUI_FillRect((Child_window_x_pos-6), (Child_window_y_pos - 31), (Child_window_x_pos + Child_window_x_size), (Child_window_y_pos + Child_window_y_size - 26));
    }
    //enter the text and image for the popup window
    else if((pMsg->hWin) == GUI_data.Window2)
    {
    GUI_Clear();
    GUI_SetBkColor(GUI_BLACK);
    WM_SetDesktopColor(GUI_BLACK);
    }



    Thanks,

    The post was edited 1 time, last by Ana ().

  • Hello,

    Please do not call the function WM_SetDesktopColor() from within a callback function. This function invalidates the background window.

    For details about invalidation please refer to the chapter "The Window Manager (WM)" in the emWin user manual.

    Best regards,
    Adrian