Displaying changing transparant text

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

  • Displaying changing transparant text

    Hello,

    I am new to Emwin, I am trying to display a transparent changing value so you can see the bitmap background through it.
    I am using SetTextMode(GUI_TM_TRANS), the first value is displayed ok but when subsequent values are displayed the last value is not cleared so you end up with a filled in square. Any one know what is the way round this ? I am sure their may many uses for displaying transparent changing text on a fixed background.

    fifo :wacko:
  • Hi,

    Attached is an example on how to display semi transparent strings. A timer changes periodically the value for the alpha channel of a color. This color is used to draw display string. In the background a bitmap gets drawn.

    If you display a string with a function like GUI_DispString() the background of the string to be displayed is solid per default. To get a transparent background you can call GUI_SetTextMode(GUI_TM_TRANS). This removes only the background color.

    To get a semi transparent string try this:

    C Source Code

    1. GUI_SetTextMode(GUI_TM_TRANS);
    2. GUI_EnableAlpha(1);
    3. GUI_SetColor(Color);
    4. GUI_DispString("TRANSPARENCY");
    5. GUI_EnableAlpha(0);


    EDIT: Added atachment

    Regards,
    Sven
    Files
    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.
  • Thanks for the response but this does not work for text that is constantly changing such as displaying a value
    I have tried the following code which is run repeatedly to display a temperature value but still end up with filled in squares.
    There has to be a way to display changing transparent text as it seems a trivial function that you would expect a graphics library to support. ?(


    while(1)
    {

    GUI_SetTextMode(GUI_TM_TRANS);
    GUI_EnableAlpha(1);
    GUI_DispDecAt(L_intTemp, 230,100,5);
    GUI_EnableAlpha(0);
    }
  • Hi,

    It does work. Take a look into the example attached. It is the same as the last but displaying a value and using one of the standard fonts.

    Regards,
    Sven
    Files
    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.
  • Thanks, I have looked at your code snippet but I still get the same problem.

    This is what I have see below. I have done what you said but it still does not work, bear in mind that I am not using windows, I am using FREERTOS.
    Regards

    Feroz

    GUI_Clear();
    GUI_SetColor(GUI_BLUE);
    GUI_SetPenSize(20);
    GUI_DrawLine(10,360, 790,360);

    GUI_SetFont(&GUI_FontD80);
    GUI_SetTextMode(GUI_TM_TRANS);

    GUI_DrawBitmap(&bmCraneSmall, 0, 0);
    Color = GUI_MAKE_COLOR(0xFF00FF00);
    Alpha = 0xFF;
    while(1)
    {
    while (GUI_Exec())
    {
    GUI_Delay(100);
    }
    Alpha = (Alpha > 4) ? Alpha - 5 : 0xFF;
    //
    // Calculate the color
    //
    Color = GUI_MAKE_COLOR(0x0000FF00 | (Alpha << 24));

    GUI_SetTextMode(GUI_TM_TRANS);
    GUI_SetFont(&GUI_FontD80);
    GUI_EnableAlpha(1);
    GUI_SetColor(Color);
    GUI_DispDecAt(L_intTemp, 230,100,5);
    GUI_EnableAlpha(0);
    L_intTemp++;
    // /* Do the background work ... Update windows etc.) */
  • Hi I think I may have not explained correctly. I don't exactly want the text to be transparent. I want the text background to be completely transparent. So instead of the text having a background of what ever color, It should not have a background hence have a transparent background. Now the SetTextMode(GUI_TM_TRANS) makes the text background transparent but when you have changing values the previous value ends up not cleared and you end up with filled in squares.

    Now there must be a way to do this I see many users wanting to display text over a bitmap.
  • Hi,

    Now I understand. You have to redraw the background of the text, too. Otherwise you will draw the text over the already displayed text and so on.

    The easiest way is to use the window manager. Simply set a callback for the background window (WM_HBKWIN) which takes care of redrawing the background if a transparent child window changes its content.

    The other way would be to manage the clearing/redrawing of the background on your own.

    Take a look into the sample attached. It shows both ways.

    Regards,
    Sven
    Files
    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.