Bitmap.MakeTransparentとは? わかりやすく解説

Bitmap.MakeTransparent メソッド ()

既定の透明色をこの Bitmap に使用します。

名前空間: System.Drawing
アセンブリ: System.Drawing (system.drawing.dll 内)
構文構文

Public Sub MakeTransparent
Dim instance As Bitmap

instance.MakeTransparent
public void MakeTransparent ()
public:
void MakeTransparent ()
public void MakeTransparent ()
public function MakeTransparent ()

戻り値
このメソッドは値を返しません。

例外例外
解説解説

システム パレットでは、ある色を既定の透明 (アルファ) 色として定義します。このメソッドでは、既定の透明色をこの Bitmapに使用します。

使用例使用例

次の例は、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 );
   }
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

Bitmap.MakeTransparent メソッド (Color)

指定の透明色をこの Bitmap に使用します。

名前空間: System.Drawing
アセンブリ: System.Drawing (system.drawing.dll 内)
構文構文

Public Sub MakeTransparent ( _
    transparentColor As Color _
)
Dim instance As Bitmap
Dim transparentColor As Color

instance.MakeTransparent(transparentColor)
public void MakeTransparent (
    Color transparentColor
)
public:
void MakeTransparent (
    Color transparentColor
)
public void MakeTransparent (
    Color transparentColor
)
public function MakeTransparent (
    transparentColor : Color
)

パラメータ

transparentColor

透明にする色を表す Color 構造体。

例外例外
使用例使用例

次の例は、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 );
   }
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

Bitmap.MakeTransparent メソッド

既定の透明色をこの Bitmap に使用します。
オーバーロードの一覧オーバーロードの一覧

名前 説明
Bitmap.MakeTransparent () 既定の透明色をこの Bitmap に使用します。
Bitmap.MakeTransparent (Color) 指定の透明色をこの Bitmap に使用します。
参照参照



英和和英テキスト翻訳

英語⇒日本語日本語⇒英語

辞書ショートカット

すべての辞書の索引

「Bitmap.MakeTransparent」の関連用語

Bitmap.MakeTransparentのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



Bitmap.MakeTransparentのページの著作権

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2026 Microsoft.All rights reserved.

©2026 GRAS Group, Inc.RSS