使用图像的路径显示图像

Display an image using the path of the image

本文关键字:图像 显示 显示图 路径      更新时间:2023-10-16

我用下面的代码为我弹出了一个图像,但它不起作用,那么view函数出了什么问题?

当我调用应用程序时,它会打开:

void Image::view(){
string app="open /Applications/GIMP.app";
system(app.c_str());}

应用程序GIMP成功打开,但当我这样做时,使用应用程序打开我的图像:

void Image::view()
string app="open /Applications/GIMP.app"+getID(); 
//getID contain the path of the image
system(app.c_str());}

这是我收到的错误消息"文件/Users/Eric/Desktop/Product/Green.ppm不存在。程序结束,退出代码为:0"

注意:一个朋友使用Xcode,因为我使用了相同的第二个功能,它与完美配合

getID()将返回/Users/Eric/Desktop/Product/Green.ppm

假设getID()的路径是正确的,则会缺少一个空格。

string app="open /Applications/GIMP.app " + getID();

目前,它正在尝试打开/Applications/GIMP.appYourFile.Extension,该操作无效。它需要/Applications/GIMP.app YourFile.Extension.

通过使用自定义工作目录(到我的产品文件)编辑方案,并更改getID()以返回其工作的图像的名称"Green.ppm"。

我想我的系统在读取目录时有问题(我之前在我的终端中遇到过这个问题),还有另一个问题需要稍后解决!