Bitmap.MakeTransparent 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
기본 투명 색을 이 Bitmap에 대해 투명하게 만듭니다.
오버로드
MakeTransparent() |
기본 투명 색을 이 Bitmap에 대해 투명하게 만듭니다. |
MakeTransparent(Color) |
해당 Bitmap의 지정된 색 투명을 만듭니다. |
MakeTransparent()
- Source:
- Bitmap.cs
- Source:
- Bitmap.cs
- Source:
- Bitmap.cs
기본 투명 색을 이 Bitmap에 대해 투명하게 만듭니다.
public:
void MakeTransparent();
public void MakeTransparent ();
member this.MakeTransparent : unit -> unit
Public Sub MakeTransparent ()
예외
Bitmap의 이미지 형식이 아이콘 형식인 경우
작업이 실패했습니다.
예제
다음 코드 예제는 Windows Forms 사용하도록 설계되었으며 이벤트 처리기의 Paint 매개 변수인 가 필요합니다.PaintEventArgse
이 코드는 시스템의 기본 투명 색을 에 myBitmap
투명하게 만든 다음 를 화면에 그립니다 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
설명
시스템 팔레트는 하나의 색을 기본 투명 또는 알파 색으로 정의합니다. 이 메서드는 이 Bitmap에 대한 기본 투명 색을 투명하게 만듭니다. 시스템에서 LightGray 지정한 투명한 색이 없는 경우 는 투명한 색입니다.
를 호출 MakeTransparent하면 이 형식이 알파 채널을 지원하므로 Format32bppArgb 비트맵이 형식으로 변환됩니다.
적용 대상
MakeTransparent(Color)
- Source:
- Bitmap.cs
- Source:
- Bitmap.cs
- Source:
- Bitmap.cs
해당 Bitmap의 지정된 색 투명을 만듭니다.
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)
매개 변수
예외
Bitmap의 이미지 형식이 아이콘 형식인 경우
작업이 실패했습니다.
예제
다음 코드 예제는 Windows Forms 사용하도록 설계되었으며 이벤트 처리기의 Paint 매개 변수인 가 필요합니다.PaintEventArgse
코드는 다음 작업을 수행합니다.
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
설명
를 호출 MakeTransparent하면 이 형식이 알파 채널을 지원하므로 Format32bppArgb 비트맵이 형식으로 변환됩니다.
적용 대상
.NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기