将ppm图像传送到eog图像查看器不起作用

问题描述 投票:1回答:1

我正在使用C ++进行图像处理项目。要显示图像,我想使用默认的ubuntu图像查看器(eog)。我的Image16类中具有可以读取和写入PPM文件的函数。我知道这些工作是因为我可以将它们写入硬盘,然后使用eog打开它们。但是,我不想将映像写入硬盘,因为我有一个SSD,每个映像约为100 Mb。我想直接将图像数据传递到eog。但是,这产生了一个错误,我不确定为什么。

ifstream in("/home/chase/Desktop/moon.ppm");
Image16 img = Image16::read_ppm(in);
in.close();

FILE* f = popen("eog /dev/stdin", "w");
img.write_ppm(f, 255);
pclose(f);

<< img src =“ https://image.soinside.com/eyJ1cmwiOiAiaHR0cHM6Ly9pLnN0YWNrLmltZ3VyLmNvbS9xUnpqNi5wbmcifQ==” alt =“在此处输入图像描述”>

我设法使其与imagemagick显示器和feh一起使用,但是我真的不喜欢那些程序。如果可能的话,我想使用eog。

c++ linux ubuntu image-processing pipe
1个回答
0
投票

如果您真的坚持使用eog,则可以将其包装。例如,粗略的bash函数

$ eog- () { cat >/tmp/img && [ -s /tmp/img ] && eog "$@" /tmp/img; }
$ pngtopnm test.png | eog-
© www.soinside.com 2019 - 2024. All rights reserved.