表紙へ

画像ファイルを表示する

 

1.単純な例


PictureBox1.BackgroundImage = Image.FromFile("C:\Winnt\隅田川.bmp")
 

 

2.グラフィックスとして表示する例


PictureBox1.Image = Image.FromFile("C:\Winnt\隅田川.bmp")
 

 

.一度メモリーに読み込んでおく例

すばやく画像を切り替えたいときはこちらの方法が優れている。

Dim MyImage As Image = Image.FromFile("C:\Winnt\隅田川.bmp")

PictureBox1.BackgroundImage = MyImage

 

.Graphicsクラスを使う例

Dim MyImage As Image = Image.FromFile("C:\Winnt\隅田川.bmp")

Dim ImagePoint As New Point(0, 0)

g.DrawImage(MyImage, ImagePoint)

注意:この例では g を Graphicsオブジェクトとする。Graphicsオブジェクトをどのように取得するかはこの例では示されていない

参考:PictureBox1 の Graphicsオブジェクトを生成する方法

Dim g As Graphics = PictureBox1.CreateGraphics