Bitmap.MakeTransparent メソッド ()
アセンブリ: System.Drawing (system.drawing.dll 内)




次の例は、Windows フォームでの使用を意図してデザインされており、Paint イベント ハンドラのパラメータである PaintEventArgse が必要です。このコードでは、システム既定の透明色を myBitmap に使用し、Bitmap を画面に描画します。
Public Sub MakeTransparent_Example1(ByVal e As PaintEventArgs) ' Create a Bitmap object from an image file. Dim myBitmap As New Bitmap("Grapes.gif") ' Draw myBitmap to the screen. e.Graphics.DrawImage(myBitmap, 0, 0, myBitmap.Width, _ myBitmap.Height) ' Make the default transparent color transparent for myBitmap. myBitmap.MakeTransparent() ' Draw the transparent bitmap to the screen. e.Graphics.DrawImage(myBitmap, myBitmap.Width, 0, myBitmap.Width, _ myBitmap.Height) End Sub
public void MakeTransparent_Example1(PaintEventArgs e) { // Create a Bitmap object from an image file. Bitmap myBitmap = new Bitmap("Grapes.gif"); // Draw myBitmap to the screen. e.Graphics.DrawImage(myBitmap, 0, 0, myBitmap.Width, myBitmap.Height); // Make the default transparent color transparent for myBitmap. myBitmap.MakeTransparent(); // Draw the transparent bitmap to the screen. e.Graphics.DrawImage(myBitmap, myBitmap.Width, 0, myBitmap.Width, myBitmap.Height); }
public: void MakeTransparent_Example1( PaintEventArgs^ e ) { // Create a Bitmap object from an image file. Bitmap^ myBitmap = gcnew Bitmap( "Grapes.gif" ); // Draw myBitmap to the screen. e->Graphics->DrawImage( myBitmap, 0, 0, myBitmap->Width, myBitmap->Height ); // Make the default transparent color transparent for myBitmap. myBitmap->MakeTransparent(); // Draw the transparent bitmap to the screen. e->Graphics->DrawImage( myBitmap, myBitmap->Width, 0, myBitmap->Width, myBitmap->Height ); }

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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Bitmap.MakeTransparent メソッド (Color)
アセンブリ: System.Drawing (system.drawing.dll 内)



次の例は、Windows フォームでの使用を意図してデザインされており、Paint イベント ハンドラのパラメータである PaintEventArgs の e が必要です。このコードは次のアクションを実行します。
Public Sub MakeTransparent_Example2(ByVal e As PaintEventArgs) ' Create a Bitmap object from an image file. Dim myBitmap As New Bitmap("Grapes.gif") ' Draw myBitmap to the screen. e.Graphics.DrawImage(myBitmap, 0, 0, myBitmap.Width, _ myBitmap.Height) ' Get the color of a background pixel. Dim backColor As Color = myBitmap.GetPixel(1, 1) ' Make backColor transparent for myBitmap. myBitmap.MakeTransparent(backColor) ' Draw the transparent bitmap to the screen. e.Graphics.DrawImage(myBitmap, myBitmap.Width, 0, myBitmap.Width, _ myBitmap.Height) End Sub
public void MakeTransparent_Example2(PaintEventArgs e) { // Create a Bitmap object from an image file. Bitmap myBitmap = new Bitmap("Grapes.gif"); // Draw myBitmap to the screen. e.Graphics.DrawImage( myBitmap, 0, 0, myBitmap.Width, myBitmap.Height); // Get the color of a background pixel. Color backColor = myBitmap.GetPixel(1, 1); // Make backColor transparent for myBitmap. myBitmap.MakeTransparent(backColor); // Draw the transparent bitmap to the screen. e.Graphics.DrawImage( myBitmap, myBitmap.Width, 0, myBitmap.Width, myBitmap.Height); }
public: void MakeTransparent_Example2( PaintEventArgs^ e ) { // Create a Bitmap object from an image file. Bitmap^ myBitmap = gcnew Bitmap( "Grapes.gif" ); // Draw myBitmap to the screen. e->Graphics->DrawImage( myBitmap, 0, 0, myBitmap->Width, myBitmap->Height ); // Get the color of a background pixel. Color backColor = myBitmap->GetPixel( 1, 1 ); // Make backColor transparent for myBitmap. myBitmap->MakeTransparent( backColor ); // Draw the transparent bitmap to the screen. e->Graphics->DrawImage( myBitmap, myBitmap->Width, 0, myBitmap->Width, myBitmap->Height ); }

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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


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

- Bitmap.MakeTransparentのページへのリンク