How to save a picture in a resource file?

The question was asked: 49 years 8 months ago   views: 7
0

Hello.
For example there is a picture on the Internet:

http://mysite.ru/work_codes/15715-83/4198923--377170.jpeg

Anyways, I have a link to the picture, I keep it in the resource file of the program, and then paste it as BackgrounImage for GroupBox?

Thanks in advance.

Asked: 01-01-1970 в 03:00:00

Answers   1

0

And why in resources? They are read-only. I think this is what you need.

Image ImageFromURL(string url) { var request = WebRequest.Create(url); var response = request.GetResponse(); var resStream = response.GetResponseStream(); var buffer = new byte[1024]; var memStream = new MemoryStream(); while (true) { var bytesRead = resStream.Read(buffer, 0, buffer.Length); if (bytesRead == 0) { break; } memStream.Write(buffer, 0, bytesRead); } var img = Image.FromStream(memStream); memStream.Close(); response.Close(); return img; }
Answered: 10-01-2013 в 16:08:18
There all as it is very difficult, I would just keep the already existing address of the picture to the images folder and then insert it as BackgrounImage for the GroupBox. - 10-01-2013 в 16:18:00
write-for-me code? You could even open source it, obviously. Updated the answer. - 10-01-2013 в 16:36:52