CF - 如何访问资源文件夹中的 .gif

发布于 2024-09-02 05:44:42 字数 165 浏览 0 评论 0原文

我已将一个简单的 .gif 文件添加到项目的 Resources 文件夹中。

现在我已经用 pictureBox 创建了一个用户控件。 我如何将 .gif 添加到 pictureBox.Image = new Bitmap(路径)。

这种情况下的路径是什么?

谢谢!

I have added a simple .gif file into Resources folder in my project.

Now i have created a user control with pictureBox.
How can i add the .gif to pictureBox.Image = new Bitmap (path).

What is the path in this case?

thanx !

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦在夏天 2024-09-09 05:44:42

我认为你可以通过以下方式做到这一点:

// Create a MemoryStream from the .gif file resource
MemoryStream ms = new MemoryStream(YourApplicationName.Properties.Resources.GifFileName);

// Instantiate a new Bitmap using the created MemoryStream
pictureBox.Image = new Bitmap(ms);

不完全确定这是否有效(目前无法测试它),但它应该为你指明正确的方向。

I think you can do it in the following way:

// Create a MemoryStream from the .gif file resource
MemoryStream ms = new MemoryStream(YourApplicationName.Properties.Resources.GifFileName);

// Instantiate a new Bitmap using the created MemoryStream
pictureBox.Image = new Bitmap(ms);

Not completely sure if this works (cannot test it at the moment) but it should point you in the right direction.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文