다음을 통해 공유


ImageAttributes.SetColorKey 메서드

정의

색상 키(투명도 범위)를 설정합니다.

오버로드

SetColorKey(Color, Color, ColorAdjustType)

지정된 범주에 대한 색상 키(투명도 범위)를 설정합니다.

SetColorKey(Color, Color)

기본 범주에 대한 색상 키를 설정합니다.

SetColorKey(Color, Color, ColorAdjustType)

Source:
ImageAttributes.cs
Source:
ImageAttributes.cs
Source:
ImageAttributes.cs

지정된 범주에 대한 색상 키(투명도 범위)를 설정합니다.

public:
 void SetColorKey(System::Drawing::Color colorLow, System::Drawing::Color colorHigh, System::Drawing::Imaging::ColorAdjustType type);
public void SetColorKey (System.Drawing.Color colorLow, System.Drawing.Color colorHigh, System.Drawing.Imaging.ColorAdjustType type);
member this.SetColorKey : System.Drawing.Color * System.Drawing.Color * System.Drawing.Imaging.ColorAdjustType -> unit
Public Sub SetColorKey (colorLow As Color, colorHigh As Color, type As ColorAdjustType)

매개 변수

colorLow
Color

로우 컬러 키 값입니다.

colorHigh
Color

하이 컬러 키 값입니다.

type
ColorAdjustType

색상 키가 설정되는 범주를 지정하는 ColorAdjustType의 요소입니다.

예제

다음 코드 예제는 Windows Forms 사용하도록 설계되었으며 이벤트 처리기의 Paint 매개 변수인 가 필요합니다.PaintEventArgse 코드는 다음 작업을 수행합니다.

  1. Image 파일 Circle.bmp 사용하여 화면에 그리는 을 엽니다.

  2. 메서드를 ImageAttributes 호출 SetColorKey 하여 개체를 만들고 해당 색 키를 설정합니다.

  3. 개체의 색 키를 ImageAttributes 사용하여 이미지를 화면에 그립니다.

private:
   void SetColorKeyExample( PaintEventArgs^ e )
   {
      // Open an Image file and draw it to the screen.
      Image^ myImage = Image::FromFile( "Circle.bmp" );
      e->Graphics->DrawImage( myImage, 20, 20 );

      // Create an ImageAttributes object and set the color key.
      Color lowerColor = Color::FromArgb( 245, 0, 0 );
      Color upperColor = Color::FromArgb( 255, 0, 0 );
      ImageAttributes^ imageAttr = gcnew ImageAttributes;
      imageAttr->SetColorKey( lowerColor, upperColor, ColorAdjustType::Default );

      // Draw the image with the color key set.
      Rectangle rect = Rectangle(150,20,100,100);
      e->Graphics->DrawImage( myImage, rect, 0, 0, 100, 100, GraphicsUnit::Pixel, imageAttr );
   }
private void SetColorKeyExample(PaintEventArgs e)
{
             
    // Open an Image file and draw it to the screen.
    Image myImage = Image.FromFile("Circle.bmp");
    e.Graphics.DrawImage(myImage, 20, 20);
             
    // Create an ImageAttributes object and set the color key.
    Color lowerColor = Color.FromArgb(245,0,0);
    Color upperColor = Color.FromArgb(255,0,0);
    ImageAttributes imageAttr = new ImageAttributes();
    imageAttr.SetColorKey(lowerColor,
        upperColor,
        ColorAdjustType.Default);
             
    // Draw the image with the color key set.
    Rectangle rect = new Rectangle(150, 20, 100, 100);
    e.Graphics.DrawImage(myImage, rect, 0, 0, 100, 100, 
        GraphicsUnit.Pixel, imageAttr);      
}
Public Sub SetColorKeyExample(ByVal e As PaintEventArgs)

    ' Open an Image file, and draw it to the screen.
    Dim myImage As Image = Image.FromFile("Circle.bmp")
    e.Graphics.DrawImage(myImage, 20, 20)

    ' Create an ImageAttributes object and set the color key.
    Dim lowerColor As Color = Color.FromArgb(245, 0, 0)
    Dim upperColor As Color = Color.FromArgb(255, 0, 0)
    Dim imageAttr As New ImageAttributes
    imageAttr.SetColorKey(lowerColor, upperColor, _
    ColorAdjustType.Default)

    ' Draw the image with the color key set.
    Dim rect As New Rectangle(150, 20, 100, 100)
    e.Graphics.DrawImage(myImage, rect, 0, 0, 100, 100, _
    GraphicsUnit.Pixel, imageAttr)
    ' Image
End Sub

설명

이 메서드는 색 범위를 투명하게 만들 수 있도록 높음 및 낮은 색 키 값을 설정합니다. 상위 및 하위 색 키의 해당 구성 요소 간에 세 가지 구성 요소(빨간색, 녹색, 파랑)가 있는 모든 색은 투명하게 만들어집니다.

개체는 ImageAttributes 기본, 비트맵, 브러시, 펜 및 텍스트의 다섯 가지 조정 범주에 대한 색 및 회색조 설정을 유지합니다. 예를 들어 기본 범주의 색 키, 비트맵 범주의 다른 색 키, 펜 범주에 대해 다른 색 키를 지정할 수 있습니다.

기본 색 조정 및 회색조 조정 설정은 자체 조정 설정이 없는 모든 범주에 적용됩니다. 예를 들어 펜 범주에 대한 조정 설정을 지정하지 않으면 기본 설정이 펜 범주에 적용됩니다.

특정 범주에 대한 색 조정 또는 회색조 조정 설정을 지정하는 즉시 기본 조정 설정이 해당 범주에 더 이상 적용되지 않습니다. 예를 들어 기본 범주에 대한 조정 설정 컬렉션을 지정한다고 가정합니다. 메서드에 전달 PenSetColorKey 하여 펜 범주의 색 키를 설정하는 경우 펜에 기본 조정 설정이 적용되지 않습니다.

적용 대상

SetColorKey(Color, Color)

Source:
ImageAttributes.cs
Source:
ImageAttributes.cs
Source:
ImageAttributes.cs

기본 범주에 대한 색상 키를 설정합니다.

public:
 void SetColorKey(System::Drawing::Color colorLow, System::Drawing::Color colorHigh);
public void SetColorKey (System.Drawing.Color colorLow, System.Drawing.Color colorHigh);
member this.SetColorKey : System.Drawing.Color * System.Drawing.Color -> unit
Public Sub SetColorKey (colorLow As Color, colorHigh As Color)

매개 변수

colorLow
Color

로우 컬러 키 값입니다.

colorHigh
Color

하이 컬러 키 값입니다.

예제

코드 예제는 메서드를 참조하세요 SetColorKey(Color, Color, ColorAdjustType) .

설명

이 메서드는 색 범위를 투명하게 만들 수 있도록 높음 및 낮은 색 키 값을 설정합니다. 상위 및 하위 색 키의 해당 구성 요소 간에 세 가지 구성 요소(빨간색, 녹색, 파랑)가 있는 모든 색은 투명하게 만들어집니다.

개체는 ImageAttributes 기본, 비트맵, 브러시, 펜 및 텍스트의 다섯 가지 조정 범주에 대한 색 및 회색조 설정을 유지합니다. 예를 들어 기본 범주의 색 키, 비트맵 범주의 다른 색 키, 펜 범주에 대해 다른 색 키를 지정할 수 있습니다.

기본 색 조정 및 회색조 조정 설정은 자체 조정 설정이 없는 모든 범주에 적용됩니다. 예를 들어 펜 범주에 대한 조정 설정을 지정하지 않으면 기본 설정이 펜 범주에 적용됩니다.

적용 대상