环境: Ubuntu 16.04
在我的应用程序中,我通过使用XGetWindowProperty原子调用_NET_WM_ICON来获得应用程序的图标。
unsigned char* data;
XGetWindowProperty(..., &data);
unsigned long* data1 = (unsigned long*) data;
long width = *data1;
long height = *(data1 + 1)
unsigned char* imageData = (unsigned char*) (data1 + 2);以下是返回数据的规范:
https://specifications.freedesktop.org/wm-spec/wm-spec-1.3.html#idm140130317554480
根据规格,返回的图像必须是压缩-32 ARGB格式.然而,我得到的图像似乎不对。最后,我用自己的图标创建了一个测试应用程序。它是一个实体图标,RGB值分别为0x20、0x40和0x80。
当我在调试器中检查变量imageData时,我看到了以下内容:
0x80, 0x40, 0x20, 0xff, 0xff, 0xff, 0xff, 0xff (repeat the pattern)它的格式似乎是BGRA和额外的四个字节的填充。
如果有人能解释这一差异,我将不胜感激。致以问候。
发布于 2017-04-06 17:22:23
我已经确认该格式确实是BGRA,并增加了4个字节的填充。我通过所有正在运行的应用程序进行枚举,并能够正确提取图标。
https://stackoverflow.com/questions/43237104
复制相似问题