_NET_WM_ICON 的图片格式 [英] Picture format for _NET_WM_ICON

查看:29
本文介绍了_NET_WM_ICON 的图片格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

环境:Ubuntu 16.04

Environment: Ubuntu 16.04

在我的应用程序中,我通过使用 _NET_WM_ICON 原子调用 XGetWindowProperty 来获取应用程序的图标.

In my app, I get an application's icon by calling XGetWindowProperty with _NET_WM_ICON atom.

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);

这里是返回数据的规格:

Here are the specs for the returned data:

https://specifications.freedesktop.org/wm-spec/wm-spec-1.3.html#idm140130317554480

根据规范,返回的图像必须是packed-32 ARGB格式.但是,我得到的图像似乎不正确.我终于用我自己的图标创建了一个测试应用程序.它是一个实心图标,RGB 值分别为 0x20、0x40 和 0x80.

According to the specs, the returned image must be in packed-32 ARGB format. However, the image I was getting did not seem right. I finally created a test application with my own icon. It is a solid icon with RGB value of 0x20, 0x40, and 0x80 respectively.

当我在调试器中检查我的变量 imageData 时,我看到的是:

When I examine my variable imageData in the debugger, here is what I see:

0x80, 0x40, 0x20, 0xff, 0xff, 0xff, 0xff, 0xff (repeat the pattern)

看起来格式是 BGRA,带有额外的四个填充字节.

It appears the format is BGRA with extra four bytes of padding.

如果有人能解释这种差异,我将不胜感激.问候.

I would appreciate it if anyone can explain this discrepancy. Regards.

推荐答案

我已经确认格式确实是 BGRA,并带有四个额外的填充字节.我枚举了所有正在运行的应用程序,并能够正确提取图标.

I have confirmed that the format is indeed BGRA with four extra bytes of padding. I enumerated through all the running applications and was able to extract the icons properly.

这篇关于_NET_WM_ICON 的图片格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆