Antialiasing and trasparency together

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

    • Antialiasing and trasparency together

      Dear all,

      I'm trying to display an image generated using a memory device with trasparency and antialiasing enabled.
      The image is displayed correctly on a black background, but if I set the background for instance to orange then the antialiased contour of the image is showing black dots.

      Source Code

      1. //[...] Initialisations and so on...
      2. // Create a memory device where to draw
      3. GUI_MEMDEV_Handle hMem = GUI_MEMDEV_CreateEx(0, 0, X_SIZE, Y_SIZE, GUI_MEMDEV_HASTRANS);
      4. // Select memory device
      5. GUI_MEMDEV_Select(hMem);
      6. // Draw something into the memory device
      7. GUI_SetPenShape(GUI_PS_ROUND);
      8. GUI_AA_FillCircle(10 * MAG, 16 * MAG, 3 * MAG);
      9. // Select LCD, display the image and delete the memory device
      10. GUI_MEMDEV_Select(0);
      11. GUI_MEMDEV_WriteAt(m_hMem, point.x, point.y);
      12. GUI_MEMDEV_Delete(hMem);
      Display All

      What shall I do to make the antialiasing work properly for orange background?

      Regards,

      Roberto
    • Hi,

      Please try calling GUI_PreserveTrans(1) after selecting the device and GUI_PreserveTrans(0) before de-selecting the device.

      This should fix the behavior.

      Here is a changed version of your code:

      C Source Code

      1. #include "DIALOG.h"
      2. /*********************************************************************
      3. *
      4. * _Test
      5. */
      6. static void _Test(void) {
      7. GUI_MEMDEV_Handle hMem;
      8. //
      9. // Create a memory device where to draw
      10. //
      11. hMem = GUI_MEMDEV_CreateEx(0, 0, 80, 80, GUI_MEMDEV_HASTRANS);
      12. //
      13. // Select memory device
      14. //
      15. GUI_MEMDEV_Select(hMem);
      16. //
      17. // Make sure that the semi transparency gets preserved
      18. //
      19. GUI_PreserveTrans(1);
      20. //
      21. // Make sure the memory device is clean
      22. //
      23. GUI_SetBkColor(GUI_TRANSPARENT);
      24. GUI_Clear();
      25. //
      26. // Draw something into the memory device
      27. //
      28. GUI_SetColor(GUI_ORANGE);
      29. GUI_AA_FillCircle(40, 40, 20);
      30. //
      31. // Make sure to disable GUI_PreserveTrans()
      32. //
      33. GUI_PreserveTrans(0);
      34. //
      35. // Deselct memory device
      36. //
      37. GUI_MEMDEV_Select(0);
      38. //
      39. // Write to LCD and delete the device
      40. //
      41. GUI_MEMDEV_WriteAt(hMem, 10, 10);
      42. GUI_MEMDEV_Delete(hMem);
      43. }
      44. /*********************************************************************
      45. *
      46. * Public code
      47. *
      48. **********************************************************************
      49. */
      50. /*********************************************************************
      51. *
      52. * MainTask
      53. */
      54. void MainTask(void) {
      55. GUI_Init();
      56. GUI_SetBkColor(GUI_LIGHTGRAY);
      57. GUI_Clear();
      58. _Test();
      59. while (1) {
      60. GUI_Delay(100);
      61. }
      62. }
      Display All
      Regards,
      Sven
      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.
    • Thank you for your help.

      I had to update from 5.28 to 5.32 to use the new function GUI_PreserveTrans().

      If I don't add this block:

      Source Code

      1. //
      2. // Make sure the memory device is clean
      3. //
      4. GUI_SetBkColor(GUI_TRANSPARENT);
      5. GUI_Clear();
      Than the look of the image is better, but if I add this block then I get a whole black background for the window. It looks like "GUI_TRANSPARENT" is not really transparent, but black...
      I tried to change GUI_USE_ARGB to 1 and 0 but no difference...

      It looks like "GUI_PreserveTrans(1);" is not making any difference, the library update alone is making things better.

      Regards,
      Roberto

      The post was edited 2 times, last by bibi: Adding information ().

    • Hi,

      Please post your configuration files?

      - LCDConf.c
      - GUIConf.c
      - GUIConf.h

      If you are using an NXP library you there are no LCDConf.c and GUIConf.c. They use two files named emwin_support.c/.h.

      I tried to change GUI_USE_ARGB to 1 and 0 but no difference...
      You shouldn't change this if you are using a precompiled library. This will change the way how emWin handles colors internally.

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