Bitmap.MakeTransparent Metoda
Definice
Důležité
Některé informace platí pro předběžně vydaný produkt, který se může zásadně změnit, než ho výrobce nebo autor vydá. Microsoft neposkytuje žádné záruky, výslovné ani předpokládané, týkající se zde uváděných informací.
Zprůhlední výchozí průhledná barva .Bitmap
Přetížení
| Name | Description |
|---|---|
| MakeTransparent() |
Zprůhlední výchozí průhledná barva .Bitmap |
| MakeTransparent(Color) |
Zprůhlední zadaná barva pro tento Bitmapparametr . |
MakeTransparent()
- Zdroj:
- Bitmap.cs
- Zdroj:
- Bitmap.cs
- Zdroj:
- Bitmap.cs
- Zdroj:
- Bitmap.cs
- Zdroj:
- Bitmap.cs
- Zdroj:
- Bitmap.cs
- Zdroj:
- Bitmap.cs
- Zdroj:
- Bitmap.cs
Zprůhlední výchozí průhledná barva .Bitmap
public:
void MakeTransparent();
public void MakeTransparent();
member this.MakeTransparent : unit -> unit
Public Sub MakeTransparent ()
Výjimky
Formát obrázku Bitmap je formát ikony.
Operace se nezdařila.
Příklady
Následující příklad kódu je určený pro použití s model Windows Forms a vyžaduje PaintEventArgse, což je parametr obslužné rutiny události Paint. Kód nastaví systém jako výchozí průhlednou barvu pro myBitmapa pak nakreslí Bitmap na obrazovku.
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
Poznámky
Systémová paleta definuje jednu barvu jako výchozí průhlednou nebo alfa barvu. Tato metoda zprůhlední výchozí průhlednou barvu pro tento Bitmap. Pokud systém nezadá žádnou průhlednou barvu, LightGray je průhledná barva.
Při volání MakeTransparentse rastrový obrázek převede do Format32bppArgb formátu, protože tento formát podporuje alfa kanál.
Platí pro
MakeTransparent(Color)
- Zdroj:
- Bitmap.cs
- Zdroj:
- Bitmap.cs
- Zdroj:
- Bitmap.cs
- Zdroj:
- Bitmap.cs
- Zdroj:
- Bitmap.cs
- Zdroj:
- Bitmap.cs
- Zdroj:
- Bitmap.cs
- Zdroj:
- Bitmap.cs
Zprůhlední zadaná barva pro tento Bitmapparametr .
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)
Parametry
Výjimky
Formát obrázku Bitmap je formát ikony.
Operace se nezdařila.
Příklady
Následující příklad kódu je určený pro použití s model Windows Forms a vyžaduje PaintEventArgse, což je parametr obslužné rutiny události Paint. Kód provede následující akce:
Získá barvu pixelu v objektu Bitmap.
Zprůhlední barva rastrového obrázku.
Nakreslí na Bitmap obrazovku.
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
Poznámky
Při volání MakeTransparentse rastrový obrázek převede do Format32bppArgb formátu, protože tento formát podporuje alfa kanál.