Image.FromFile メソッド (String, Boolean)
アセンブリ: System.Drawing (system.drawing.dll 内)

Public Shared Function FromFile ( _ filename As String, _ useEmbeddedColorManagement As Boolean _ ) As Image
Dim filename As String Dim useEmbeddedColorManagement As Boolean Dim returnValue As Image returnValue = Image.FromFile(filename, useEmbeddedColorManagement)
戻り値
このメソッドが作成する Image。


このファイルは Image が破棄されるまでロックされます。
ファイルのイメージ形式が有効でない場合、または、そのファイルのピクセル形式が GDI+ でサポートされていない場合、このメソッドは OutOfMemoryException 例外をスローします。
useEmbeddedColorManagement パラメータは、イメージ ファイルに埋め込まれた色管理情報に従って、新しい Image に色補正を適用させるかどうかを指定します。埋め込み情報には、ICC (International Color Consortium) プロファイル、ガンマ値、および色度情報を含めることができます。

FromFile メソッドを使用して、新しいビットマップを取得する方法を次のコード例に示します。TextureBrushTextureBrush の例も示します。
この例は、Windows フォームでの使用を意図してデザインされています。Button2 という名前のボタンを格納するフォームを作成します。コードをフォームに貼り付け、Button2_Click メソッドをボタンの Click イベントに関連付けます。
Private Sub Button2_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles Button2.Click Try Dim image1 As Bitmap = _ CType(Image.FromFile("C:\Documents and Settings\" _ & "All Users\Documents\My Music\music.bmp", True), Bitmap) Dim texture As New TextureBrush(image1) texture.WrapMode = Drawing2D.WrapMode.Tile Dim formGraphics As Graphics = Me.CreateGraphics() formGraphics.FillEllipse(texture, _ New RectangleF(90.0F, 110.0F, 100, 100)) formGraphics.Dispose() Catch ex As System.IO.FileNotFoundException MessageBox.Show("There was an error opening the bitmap." _ & "Please check the path.") End Try End Sub
private void Button2_Click(System.Object sender, System.EventArgs e) { try { Bitmap image1 = (Bitmap) Image.FromFile(@"C:\Documents and Settings\" + @"All Users\Documents\My Music\music.bmp", true); TextureBrush texture = new TextureBrush(image1); texture.WrapMode = System.Drawing.Drawing2D.WrapMode.Tile; Graphics formGraphics = this.CreateGraphics(); formGraphics.FillEllipse(texture, new RectangleF(90.0F, 110.0F, 100, 100)); formGraphics.Dispose(); } catch(System.IO.FileNotFoundException) { MessageBox.Show("There was an error opening the bitmap." + "Please check the path."); } }
private: void Button2_Click( System::Object^ /*sender*/, System::EventArgs^ /*e*/ ) { try { Bitmap^ image1 = dynamic_cast<Bitmap^>(Image::FromFile( "C:\\Documents and Settings\\" "All Users\\Documents\\My Music\\music.bmp", true )); TextureBrush^ texture = gcnew TextureBrush( image1 ); texture->WrapMode = System::Drawing::Drawing2D::WrapMode::Tile; Graphics^ formGraphics = this->CreateGraphics(); formGraphics->FillEllipse( texture, RectangleF(90.0F,110.0F,100,100) ); delete formGraphics; } catch ( System::IO::FileNotFoundException^ ) { MessageBox::Show( "There was an error opening the bitmap." "Please check the path." ); } }
private void button2_Click(Object sender, System.EventArgs e) { try { Bitmap image1 = ((Bitmap)(Image.FromFile( "C:\\Documents and Settings\\" + "All Users\\Documents\\My Music\\music.bmp", true))); TextureBrush texture = new TextureBrush(image1); texture.set_WrapMode(System.Drawing.Drawing2D.WrapMode.Tile); Graphics formGraphics = this.CreateGraphics(); formGraphics.FillEllipse(texture, new RectangleF(90, 110, 100,100)); formGraphics.Dispose(); } catch (System.IO.FileNotFoundException exp) { MessageBox.Show(("There was an error opening the bitmap." + "Please check the path.")); } } //button2_Click

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Image.FromFile メソッド (String)
アセンブリ: System.Drawing (system.drawing.dll 内)

Dim filename As String Dim returnValue As Image returnValue = Image.FromFile(filename)
戻り値
このメソッドが作成する Image。


このファイルは Image が破棄されるまでロックされます。
ファイルのイメージ形式が有効でない場合、または、そのファイルのピクセル形式が GDI+ でサポートされていない場合、このメソッドは OutOfMemoryException 例外をスローします。

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Image.FromFile メソッド
Weblioに収録されているすべての辞書からImage.FromFileを検索する場合は、下記のリンクをクリックしてください。

- Image.FromFileのページへのリンク