Troubles with GUI_MEMDEV_RotateHQ

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

  • Troubles with GUI_MEMDEV_RotateHQ

    Newer to using emWin, but I am trying to follow an example and do not understand why this is not working. I am not sure if it is a limitation or user error.

    I am trying to draw a single Char with a Memory Device, rotate it and display it. This works well until I try to make it transparent. My end goal is to create text along a curve/arc.

    I am using a NXP LPC4357. Below is the code I currently have:

    C Source Code

    1. GUI_MEMDEV_Handle hMemSource;
    2. GUI_MEMDEV_Handle hMemDest;
    3. GUI_RECT RectSource = {0, 0, 24, 20};
    4. GUI_RECT RectDest = {0, 0, 24, 22};
    5. GUI_SetColor(GUI_BLUE);
    6. GUI_FillRect(0,0,320,240);
    7. hMemSource = GUI_MEMDEV_CreateFixed(RectSource.x0, RectSource.y0,
    8. RectSource.x1 - RectSource.x0 + 1,
    9. RectSource.y1 - RectSource.y0 + 1,
    10. GUI_MEMDEV_NOTRANS,
    11. GUI_MEMDEV_APILIST_32, GUICC_8888);
    12. hMemDest = GUI_MEMDEV_CreateFixed(RectDest.x0, RectDest.y0,
    13. RectDest.x1 - RectDest.x0 + 1,
    14. RectDest.y1 - RectDest.y0 + 1,
    15. GUI_MEMDEV_NOTRANS,
    16. GUI_MEMDEV_APILIST_32, GUICC_8888);
    17. GUI_MEMDEV_Select(hMemSource);
    18. GUI_SetColor(GUI_WHITE);
    19. GUI_SetFont(&GUI_Font20B_ASCII);
    20. GUI_SetTextMode(GUI_TEXTMODE_TRANS);
    21. GUI_DispCharAt('A',(RectSource.x1 + RectSource.x0)/2-7,(RectSource.y1 + RectSource.y0)/2-14);
    22. GUI_MEMDEV_RotateHQ(hMemSource, hMemDest,
    23. (RectDest.x1 - RectSource.x1) / 2,
    24. (RectDest.y1 - RectSource.y1) / 2,
    25. 45 * 1000,
    26. 1000);
    27. GUI_MEMDEV_CopyToLCDAt(hMemSource, 10, (RectDest.y1 - RectSource.y1) / 2);
    28. GUI_MEMDEV_CopyToLCDAt(hMemDest, 160, 120);
    Display All


    Changing GUI_MEMDEV_NOTRANS to GUI_MEMDEV_HASTRANS works for the Source but when rotating and putting into the Destination, the Destination does not display correctly. (Also this is a stripped down version of the example for rotate in the documentation).

    Suggestions?
    Thank you.
  • Hello,

    It is required to have both Memory Devices filled with transparency. Further it is required to use the functions GUI_MEMDEV_Write...() in order to consider transparency. Please try the following code snippet:

    C Source Code

    1. GUI_MEMDEV_Handle hMemSource;
    2. GUI_MEMDEV_Handle hMemDest;
    3. GUI_RECT RectSource = {0, 0, 24, 20};
    4. GUI_RECT RectDest = {0, 0, 24, 22};
    5. GUI_Init();
    6. GUI_SetColor(GUI_BLUE);
    7. GUI_FillRect(0,0,320,240);
    8. hMemSource = GUI_MEMDEV_CreateFixed(RectSource.x0, RectSource.y0, RectSource.x1 - RectSource.x0 + 1, RectSource.y1 - RectSource.y0 + 1, GUI_MEMDEV_NOTRANS, GUI_MEMDEV_APILIST_32, GUICC_8888);
    9. hMemDest = GUI_MEMDEV_CreateFixed(RectDest.x0, RectDest.y0, RectDest.x1 - RectDest.x0 + 1, RectDest.y1 - RectDest.y0 + 1, GUI_MEMDEV_NOTRANS, GUI_MEMDEV_APILIST_32, GUICC_8888);
    10. GUI_MEMDEV_Select(hMemSource);
    11. GUI_SetBkColor(GUI_TRANSPARENT);
    12. GUI_Clear();
    13. GUI_SetColor(GUI_WHITE);
    14. GUI_SetFont(&GUI_Font20B_ASCII);
    15. GUI_SetTextMode(GUI_TEXTMODE_TRANS);
    16. GUI_DispCharAt('A',(RectSource.x1 + RectSource.x0)/2-7,(RectSource.y1 + RectSource.y0)/2-14);
    17. GUI_MEMDEV_Select(hMemDest);
    18. GUI_SetBkColor(GUI_TRANSPARENT);
    19. GUI_Clear();
    20. GUI_MEMDEV_RotateHQ(hMemSource, hMemDest, (RectDest.x1 - RectSource.x1) / 2, (RectDest.y1 - RectSource.y1) / 2, 45 * 1000, 1000);
    21. GUI_MEMDEV_Select(0);
    22. GUI_MEMDEV_Write(hMemSource);
    23. GUI_MEMDEV_WriteAt(hMemDest, 160, 120);
    Display All

    Best regards,
    Adrian
  • Thank you, this worked perfectly.

    My next step I thought was gonna be easy, but I am missing how to do it correctly. If I need to rotate multiple memory devices (1 for each char in my string), can I "combine" multiple memory devices before doing a MEMDEV_Write() ?

    Thank you again.