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.
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
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
- static void _ReplaceColors(GUI_MEMDEV_Handle hMem, U32 Color) {
- U32 * pData;
- U32 ColorOld;
- int i, j, xSize, ySize;
- xSize = GUI_MEMDEV_GetXSize(hMem);
- ySize = GUI_MEMDEV_GetYSize(hMem);
- pData = (U32 *)GUI_MEMDEV_GetDataPtr(hMem);
- for (i = 0; i < ySize; i++) {
- for (j = 0; j < xSize; j++) {
- ColorOld = *pData;
- if (ColorOld != GUI_TRANSPARENT) {
- *pData = Color | ((ColorOld & 0xFF) ^ 0xFF) << 24; //① confusing , can not understand
- }
- *pData++;
- }
- }
- }
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 ().