我尝试在 C 中做这样的事情,但我不知道如何:(:
$: xwd -silent -root | convert xwd:- -crop 1920x1080+0+0 test.png
与执行。
现在我只能做这样的事情:
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
int main(int argc, char *argv)
{
char *binaryPath = "/usr/bin/xwd";
char *arg1 = "-root";
char *arg2 = "-silent";
int fd; /*file descriptor to the file we will redirect ls's output*/
if((fd = open("xwd1.xwd", O_RDWR | O_CREAT , 0666))==-1){ /*open the file */
perror("open");
return 1;
}
dup2(fd,STDOUT_FILENO);
dup2(fd,STDERR_FILENO);
close(fd);
execl( binaryPath , binaryPath ,arg1,arg2, (char *) 0 );
return 0;
}
它将屏幕转储写入文件 xwd1.xwd 但我不知道如何使用转换制作管道。感谢所有信息和帮助。