How to change background color of an image when image is a transparent image.

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

    • Hi,

      Please give the example attached a try. A PNG gets drawn with white as back ground color and a window on top. The window gets hidden and shown again each second.

      Regards,
      Sven
      Files
      • PNGwBKColor.zip

        (8.35 kB, downloaded 255 times, last: )
      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.
    • ok let me explain you again.
      I have a window on that i want to create a button on that button i want to set image for pressed and unpressed both. image which i am using is transparent. I want the same image to be used and just change the background color in callback function of that button like this.

      static void _cbButton(WM_MESSAGE * pMsg)
      {
      switch (pMsg->MsgId) {
      case WM_PAINT:
      if(BUTTON_IsPressed(pMsg->hWin))
      {
      GUI_SetBkColor(GUI_RED);
      GUI_Clear();
      GUI_DrawBitmap(&buttonicon1,0,0);
      }
      else
      {
      GUI_SetBkColor(GUI_GREEN);
      GUI_Clear();
      GUI_DrawBitmap(&buttonicon1,0,0);
      }
      break;
      default:
      BUTTON_Callback(pMsg);
      break;
      }
      }

      THIS FUNCTION will set the background properly. now at some point of time popup comes on top of that window where button was drawn. when that popup goes (deleted) background color of that button also went off and now it is black. i am not able to set the background color again.. hope you understood. :)
    • Hi,

      I have no issue drawing a bitmap on button. No matter if a window gets on top of or not.

      Try the example attached.

      Regards,
      Sven
      Files
      • Example.zip

        (21.04 kB, downloaded 223 times, last: )
      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.