Bitmap.MakeTransparent メソッド ()とは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > 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使用します
参照参照



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

Bitmap.MakeTransparent メソッド ()のお隣キーワード
検索ランキング

   

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



Bitmap.MakeTransparent メソッド ()のページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2024 GRAS Group, Inc.RSS