Skip to content

Instantly share code, notes, and snippets.

@EsProgram
Created June 3, 2014 12:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EsProgram/aacaf92b903896bfe435 to your computer and use it in GitHub Desktop.
Save EsProgram/aacaf92b903896bfe435 to your computer and use it in GitHub Desktop.
using System;
using System.Net;
using System.IO;
using System.Windows.Forms;
using System.Drawing;
class ストリームからイメージを作成する
{
[STAThread]
static void Main(string[] args)
{
Application.Run(new MyForm());
}
}
class MyForm : Form
{
public MyForm()
{
String uri = @"http://livedoor.blogimg.jp/borocso/imgs/3/6/36b40029.jpg";
PictureBox pic = new PictureBox();
this.Controls.Add(pic);
this.Size = new Size(600, 400);
pic.PointToClient(new Point(0, 0));
pic.ClientSize = this.ClientSize;
Image image = null;
WebClient wc = new WebClient();
using(Stream stream = wc.OpenRead(uri))
{
if(wc.ResponseHeaders["Content-Type"].StartsWith("image/"))
{
image = Image.FromStream(stream);
pic.Image = image;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment