Problems about speedometer demo

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

  • Problems about speedometer demo

    Hi,
    I attempted to modify the speedometer demo and apply it to our embedded applications based on LPC1788 board, when analyzing the demo code, I am confused by one line in function "_ReplaceColorsGradient" , c/c++ code as follows.the line was highlighted by red color.

    C Source Code

    1. static void _ReplaceColors(GUI_MEMDEV_Handle hMem, U32 Color) {
    2. U32 * pData;
    3. U32 ColorOld;
    4. int i, j, xSize, ySize;
    5. xSize = GUI_MEMDEV_GetXSize(hMem);
    6. ySize = GUI_MEMDEV_GetYSize(hMem);
    7. pData = (U32 *)GUI_MEMDEV_GetDataPtr(hMem);
    8. for (i = 0; i < ySize; i++) {
    9. for (j = 0; j < xSize; j++) {
    10. ColorOld = *pData;
    11. if (ColorOld != GUI_TRANSPARENT) {
    12. *pData = Color | ((ColorOld & 0xFF) ^ 0xFF) << 24; //① confusing , can not understand
    13. }
    14. *pData++;
    15. }
    16. }
    17. }
    Display All



    Since I have trouble in understanding this line, so I have did an experiment, just remove the line "*pData = Color |((ColorOld & 0xFF) ^ 0xFF) << 24;", finally I found that the drawn result went bad. I just want to know the mechanism of this sentence, So can you give me a detail explanation about this, thanks for your help!

    Best regards,
    Nion

    The post was edited 7 times, last by Nion ().