如何使用c#将图像加载到图像对象 [英] how to load image to image object using c#

查看:93
本文介绍了如何使用c#将图像加载到图像对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码无法正常工作,找不到显示文件,任何人都可以帮助我



This is my code its not working, its showing file not found any one can help me please

string myImagePath = @&quoTempImage\TempImage.jpg";
           TempImage = Image.FromFile(myImagePath);
           pictureBox2.Image = TempImage;

推荐答案

好尝试使用完整路径。如果那个工作,你的可执行文件运行在这个相对路径对文件无效的地方。请注意你的代码被编译为 bin\debug bin \ release
Well, try with full path. If that one works, your executable runs somewhere where this relative path is not valid to the file. Be aware that your code is compiled to bin\debug or bin\release.


您是否正确使用了代码。

以下代码有语法错误。

string myImagePath = @& quoTempImage\TempImage.jpg;

如果你想使用相对路径,你需要将图像添加到项目解决方案中。

以下是在Pi中加载图像的代码cture Box。

Have you past code properly.
Following code have syntax error.
string myImagePath = @&quoTempImage\TempImage.jpg";
If you want to use relative path you need to add image in to you project solution.
Following is the code to load image in Picture Box.
var image = Image.FromFile(realtiveImagePath);
          pictureBox1.Image = image;


这篇关于如何使用c#将图像加载到图像对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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