[EMWIN]关于 GUI_GetPixelIndex 使用的问题

 在模拟器上和st单片机上使用以下代码:

 GUI_COLOR color0,color1;

color0 = GUI_GetPixelIndex(rect.x1+1, rect.y0);
color1 = GUI_GetPixelIndex(rect.x1+1, rect.y1);

 

 左边模拟器,右边st单片机(keil)

发现读取出来的色值不一样,于是折腾下找到解决办法:

单片机上使用

color0 = GUI_Index2Color(GUI_GetPixelIndex(rect.x1+1, rect.y0));
color1 = GUI_Index2Color(GUI_GetPixelIndex(rect.x1+1, rect.y1));

代码如果要兼容单片机和模拟器 可以这么写:

#ifdef WIN32
    color0 = GUI_GetPixelIndex(rect.x1+1, rect.y0);
    color1 = GUI_GetPixelIndex(rect.x1+1, rect.y1);
#else
    color0 = GUI_Index2Color(GUI_GetPixelIndex(rect.x1+1, rect.y0));
    color1 = GUI_Index2Color(GUI_GetPixelIndex(rect.x1+1, rect.y1));
#endif

就能获取正确的像素颜色,具体原因没有细查,请知道的小伙伴回复下,让后边的小伙伴知道怎么回事,谢谢。

 特此记录。

相关问题有 :

1.    http://bbs.armfly.com/read.php?tid=6584

2.   http://bbs.21ic.com/forum.php?mod=viewthread&tid=1570306

如果问题解决起来不妥或者有更好的解决办法,麻烦请告知,帮助曾经和你一样的入门者,谢谢。
原文地址:https://www.cnblogs.com/ourran/p/6627417.html