相关疑难解决方法(0)

从System.Drawing.Bitmap加载WPF BitmapImage

我有一个a的实例,System.Drawing.Bitmap并希望以一种形式将它提供给我的WPF应用程序System.Windows.Media.Imaging.BitmapImage.

对此最好的方法是什么?

c# wpf bitmap

217
推荐指数
8
解决办法
21万
查看次数

从资源加载图像

我想加载这样的图像:

void info(string channel)
{
    //Something like that
    channelPic.Image = Properties.Resources.+channel
}
Run Code Online (Sandbox Code Playgroud)

因为我不想这样做

void info(string channel)
{
    switch(channel)
    {
        case "chan1":
            channelPic.Image = Properties.Resources.chan1;
            break;
        case "chan2":
            channelPic.Image = Properties.Resources.chan2;
            break;
    }
}
Run Code Online (Sandbox Code Playgroud)

这样的事情可能吗?

c# resources image picturebox

29
推荐指数
3
解决办法
13万
查看次数

在C#winform中,如何使用exe文件附加资源(例如图像)?

我不知道我是否正确,但基本上发生了什么是我创建了一个winform应用程序从资源文件夹加载其图像..问题是,当我构建项目并获得exe并将其提供给朋友,他不会像我那样拥有那个资源文件夹,所以他会收到一个错误说丢失文件.

我怎么能以某种方式混合,组合或附加图像与我的应用程序?

c# winforms

19
推荐指数
2
解决办法
3万
查看次数

如何在C#中从项目的Resources文件夹中检索Image

我在项目的资源文件夹中有一些图像,但我想从项目的这些资源文件中更改图片框

c# resources winforms

12
推荐指数
1
解决办法
4万
查看次数

C#从try-catch块返回

为什么我不能从try块中返回我从url获得的图像?对不起英语不好:(.

这是我得到的错误:

退货声明丢失

    public static Image GetExternalImg(string name, string size)
    {
        try
        {
            // Get the image from the web.
            WebRequest req = WebRequest.Create(String.Format("http://www.picturesite.com/picture.png", name, size));
            // Read the image that we get in a stream.
            Stream stream = req.GetResponse().GetResponseStream();
            // Save the image from the stream that we are rreading.
            Image img = Image.FromStream(stream);
            // Save the image to local storage.
            img.Save(Environment.CurrentDirectory + "\\images\\" + name + ".png");
            return img;
        }
        catch (Exception)
        {

        }
    }
Run Code Online (Sandbox Code Playgroud)

任何帮助将不胜感激,因为我现在卡住了:(.

c# return try-catch

3
推荐指数
1
解决办法
1万
查看次数

标签 统计

c# ×5

resources ×2

winforms ×2

bitmap ×1

image ×1

picturebox ×1

return ×1

try-catch ×1

wpf ×1