Xcursor
跳转到导航
跳转到搜索
对应的库为 libxcursor,详可 man Xcursor
。
示例
读取 Xcursor 文件:
#include<stdio.h>
#include<stdlib.h>
#include<X11/Xcursor/Xcursor.h>
int main(int argc, char **argv){
if(argc != 2){
fprintf(stderr, "please give a Xcursor file\n");
exit(1);
}
FILE* f = fopen(argv[1], "rb");
if(f == NULL){
perror("error open file");
exit(2);
}
XcursorImages* xims = XcursorFileLoadAllImages(f);
fclose(f);
XcursorImage* xim = xims->images[0];
printf("size: %ux%u hotspot: (%u, %u)\n", xim->width, xim->height, xim->xhot, xim->yhot);
for(int h=0; h<xim->height; h++) {
for(int w=0; w<xim->width; w++) {
printf("%08x ", xim->pixels[h * xim->width + w]);
}
printf("\n");
}
return 0;
}
编译命令:
gcc cursorconvert.c -o cursorconvert -lXcursor
参见
- xcur2png,转换的结果有些不正确,返回值为转换的图片个数
- gimp-plugin-xmc,一个 gimp 插件,可以导入/导出 Xcursor 文件