다음을 통해 공유


ImageAttributes.SetThreshold 메서드

정의

임계값(투명도 범위)를 설정합니다.

오버로드

SetThreshold(Single)

기본 범주에 대한 임계값(투명도 범위)을 설정합니다.

SetThreshold(Single, ColorAdjustType)

지정된 범주에 대한 임계값(투명도 범위)을 설정합니다.

SetThreshold(Single)

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

기본 범주에 대한 임계값(투명도 범위)을 설정합니다.

public:
 void SetThreshold(float threshold);
public void SetThreshold (float threshold);
member this.SetThreshold : single -> unit
Public Sub SetThreshold (threshold As Single)

매개 변수

threshold
Single

임계값을 지정하는 실수입니다.

예제

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

  1. Image 열고 화면에 그립니다.

  2. 메서드를 사용하여 개체를 ImageAttributes 만들고 해당 임계값을 SetThreshold 설정합니다.

  3. 개체의 임계값 ImageAttributes 을 사용하여 이미지를 화면에 그립니다.

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

   // Create an ImageAttributes object, and set its color threshold.
   ImageAttributes^ imageAttr = gcnew ImageAttributes;
   imageAttr->SetThreshold( 0.7f );

   // Draw the image with the colors bifurcated.
   Rectangle rect = Rectangle(300,20,200,200);
   e->Graphics->DrawImage( myImage, rect, 0, 0, 200, 200, GraphicsUnit::Pixel, imageAttr );
}
private void SetThresholdExample(PaintEventArgs e)
{
             
    // Open an Image file, and draw it to the screen.
    Image myImage = Image.FromFile("Camera.jpg");
    e.Graphics.DrawImage(myImage, 20, 20);
             
    // Create an ImageAttributes object, and set its color threshold.
    ImageAttributes imageAttr = new ImageAttributes();
    imageAttr.SetThreshold(0.7f);
             
    // Draw the image with the colors bifurcated.
    Rectangle rect = new Rectangle(300, 20, 200, 200);
    e.Graphics.DrawImage(myImage, rect, 0, 0, 200, 200, 
        GraphicsUnit.Pixel, imageAttr);    
}
Public Sub SetThresholdExample(ByVal e As PaintEventArgs)

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

    ' Create an ImageAttributes object, and set its color threshold.
    Dim imageAttr As New ImageAttributes
    imageAttr.SetThreshold(0.7F)

    ' Draw the image with the colors bifurcated.
    Dim rect As New Rectangle(300, 20, 200, 200)
    e.Graphics.DrawImage(myImage, rect, 0, 0, 200, 200, _
    GraphicsUnit.Pixel, imageAttr)
End Sub

설명

임계값은 각 색 구성 요소에 대한 구분점을 지정하는 0부터 1까지의 값입니다. 예를 들어 임계값이 0.7로 설정되어 있고 빨간색, 녹색 및 파란색 구성 요소가 각각 230, 50 및 220인 색을 렌더링한다고 가정합니다. 빨간색 구성 요소(230)가 0.7x255보다 크므로 빨간색 구성 요소가 255(전체 강도)로 변경됩니다. 녹색 구성 요소(50)가 0.7x255보다 작으므로 녹색 구성 요소가 0으로 변경됩니다. 파란색 구성 요소(220)가 0.7x255보다 크므로 파란색 구성 요소가 255로 변경됩니다.

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

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

적용 대상

SetThreshold(Single, ColorAdjustType)

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

지정된 범주에 대한 임계값(투명도 범위)을 설정합니다.

public:
 void SetThreshold(float threshold, System::Drawing::Imaging::ColorAdjustType type);
public void SetThreshold (float threshold, System.Drawing.Imaging.ColorAdjustType type);
member this.SetThreshold : single * System.Drawing.Imaging.ColorAdjustType -> unit
Public Sub SetThreshold (threshold As Single, type As ColorAdjustType)

매개 변수

threshold
Single

최대값 또는 최소값으로 매핑될 색을 정렬하기 위해 중단점으로 사용되는 0.0~1.0 사이의 임계값입니다.

type
ColorAdjustType

색 임계값이 설정되는 범주를 지정하는 ColorAdjustType의 요소입니다.

예제

코드 예제는 메서드를 참조하세요 SetThreshold(Single) .

설명

임계값은 각 색 구성 요소에 대한 구분점을 지정하는 0부터 1까지의 값입니다. 예를 들어 임계값이 0.7로 설정되어 있고 빨간색, 녹색 및 파란색 구성 요소가 각각 230, 50 및 220인 색을 렌더링한다고 가정합니다. 빨간색 구성 요소(230)가 0.7x255보다 크므로 빨간색 구성 요소가 255(전체 강도)로 변경됩니다. 녹색 구성 요소(50)가 0.7x255보다 작으므로 녹색 구성 요소가 0으로 변경됩니다. 파란색 구성 요소(220)가 0.7x255보다 크므로 파란색 구성 요소가 255로 변경됩니다.

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

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

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

적용 대상