Bitmap.MakeTransparent Yöntem

Tanım

Bu Bitmapiçin varsayılan saydam rengi saydam yapar.

Aşırı Yüklemeler

Name Description
MakeTransparent()

Bu Bitmapiçin varsayılan saydam rengi saydam yapar.

MakeTransparent(Color)

Bu Bitmapiçin belirtilen rengi saydam yapar.

MakeTransparent()

Kaynak:
Bitmap.cs
Kaynak:
Bitmap.cs
Kaynak:
Bitmap.cs
Kaynak:
Bitmap.cs
Kaynak:
Bitmap.cs
Kaynak:
Bitmap.cs
Kaynak:
Bitmap.cs
Kaynak:
Bitmap.cs

Bu Bitmapiçin varsayılan saydam rengi saydam yapar.

public:
 void MakeTransparent();
public void MakeTransparent();
member this.MakeTransparent : unit -> unit
Public Sub MakeTransparent ()

Özel durumlar

öğesinin Bitmap görüntü biçimi bir simge biçimidir.

İşlem başarısız oldu.

Örnekler

Aşağıdaki kod örneği Windows Forms ile kullanılmak üzere tasarlanmıştır ve PaintEventArgs olay işleyicisinin bir parametresi olan ePaint gerektirir. Kod, sistem varsayılan saydam rengini için myBitmapsaydam hale getirir ve ardından öğesini ekrana çizer Bitmap .

private:
   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 );
   }
private 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);
}
Private 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

Açıklamalar

Sistem paleti bir rengi varsayılan saydam veya alfa rengi olarak tanımlar. Bu yöntem, bu Bitmapiçin varsayılan saydam rengi saydam hale getirir. Sistem tarafından saydam renk belirtilmemişse, LightGray saydam renktir.

çağırdığınızda MakeTransparentbit eşlem biçimine Format32bppArgb dönüştürülür, bu biçim bir alfa kanalını destekler.

Şunlara uygulanır

MakeTransparent(Color)

Kaynak:
Bitmap.cs
Kaynak:
Bitmap.cs
Kaynak:
Bitmap.cs
Kaynak:
Bitmap.cs
Kaynak:
Bitmap.cs
Kaynak:
Bitmap.cs
Kaynak:
Bitmap.cs
Kaynak:
Bitmap.cs

Bu Bitmapiçin belirtilen rengi saydam yapar.

public:
 void MakeTransparent(System::Drawing::Color transparentColor);
public void MakeTransparent(System.Drawing.Color transparentColor);
member this.MakeTransparent : System.Drawing.Color -> unit
Public Sub MakeTransparent (transparentColor As Color)

Parametreler

transparentColor
Color

Saydam Color yapmak için rengi temsil eden yapı.

Özel durumlar

öğesinin Bitmap görüntü biçimi bir simge biçimidir.

İşlem başarısız oldu.

Örnekler

Aşağıdaki kod örneği Windows Forms ile kullanılmak üzere tasarlanmıştır ve PaintEventArgs olay işleyicisinin bir parametresi olan ePaint gerektirir. Kod aşağıdaki eylemleri gerçekleştirir:

  • içindeki bir pikselin Bitmaprengini alır.

  • Bu rengi bit eşlem için saydam hale getirir.

  • öğesini ekrana çizer Bitmap .

private:
   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 );
   }
private 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);
}
Private 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

Açıklamalar

çağırdığınızda MakeTransparentbit eşlem biçimine Format32bppArgb dönüştürülür, bu biçim bir alfa kanalını destekler.

Şunlara uygulanır