Share via


ImageAttributes.SetGamma 메서드

정의

감마 값을 설정합니다.

오버로드

SetGamma(Single)

기본 범주에 대한 감마 값을 설정합니다.

SetGamma(Single, ColorAdjustType)

지정된 범주에 대한 감마 값을 설정합니다.

SetGamma(Single)

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

기본 범주에 대한 감마 값을 설정합니다.

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

매개 변수

gamma
Single

감마 보정 값입니다.

예제

다음 코드 예제는 Windows Forms 사용하도록 설계되었으며 이벤트 처리기의 Paint 매개 변수인 가 필요합니다.PaintEventArgse 또한 이미지 파일 경로를 시스템에서 유효한 경로 및 이미지 이름으로 변경해야 합니다. 코드는 다음 작업을 수행합니다.

  1. Image 파일 Camera.jpg 사용하는 을 열고 감마의 기본값을 사용하여 화면에 그립니다.

  2. 메서드를 ImageAttributes 호출하여 개체를 만들고 감마를 2.2로 SetGamma 설정합니다.

  3. 개체에 설정된 감마 값을 사용하여 이미지(두 번째 카메라)를 ImageAttributes 화면에 그립니다.

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

      // Create an ImageAttributes object and set the gamma to 2.2.
      System::Drawing::Imaging::ImageAttributes^ imageAttr = 
          gcnew System::Drawing::Imaging::ImageAttributes;
      imageAttr->SetGamma( 2.2f );

      // Draw the image with gamma set to 2.2.
      Rectangle rect = Rectangle(250,20,200,200);
      e->Graphics->DrawImage( myImage, rect, 0, 0, 200, 200, GraphicsUnit::Pixel, imageAttr );
   }
private void SetGammaExample(PaintEventArgs e)
{
             
    // Create an Image object from the file Camera.jpg, and draw it to
    // the screen.
    Image myImage = Image.FromFile("Camera.jpg");
    e.Graphics.DrawImage(myImage, 20, 20);
             
    // Create an ImageAttributes object and set the gamma to 2.2.
    System.Drawing.Imaging.ImageAttributes imageAttr = 
           new System.Drawing.Imaging.ImageAttributes();
    imageAttr.SetGamma(2.2f);
             
    // Draw the image with gamma set to 2.2.
    Rectangle rect = new Rectangle(250, 20, 200, 200);
    e.Graphics.DrawImage(myImage, rect, 0, 0, 200, 200, 
        GraphicsUnit.Pixel, imageAttr);    
}
Public Sub SetGammaExample(ByVal e As PaintEventArgs)

    ' Create an Image object from the file Camera.jpg, and draw

    ' it to screen.
    Dim myImage As Image = Image.FromFile("Camera.jpg")
    e.Graphics.DrawImage(myImage, 20, 20)

    ' Create an ImageAttributes object and set the gamma to 2.2.
    Dim imageAttr As New System.Drawing.Imaging.ImageAttributes
    imageAttr.SetGamma(2.2F)

    ' Draw the image with gamma set to 2.2.
    Dim rect As New Rectangle(250, 20, 200, 200)
    e.Graphics.DrawImage(myImage, rect, 0, 0, 200, 200, _
    GraphicsUnit.Pixel, imageAttr)
    ' Image
End Sub

설명

매개 변수의 gamma 일반적인 값은 1.0에서 2.2까지입니다. 그러나 0.1에서 5.0까지의 값은 경우에 따라 유용할 수 있습니다.

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

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

일반적인 범위를 벗어난 감마 값은 이전 CRT 모니터 또는 산업 환경 또는 창 디스플레이와 같은 비정상적인 조명 조건에 있는 모니터에 유용할 수 있습니다.

적용 대상

SetGamma(Single, ColorAdjustType)

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

지정된 범주에 대한 감마 값을 설정합니다.

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

매개 변수

gamma
Single

감마 보정 값입니다.

type
ColorAdjustType

감마 값이 설정되는 범주를 지정하는 ColorAdjustType 열거형의 요소입니다.

예제

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

설명

매개 변수의 gamma 일반적인 값은 1.0에서 2.2까지입니다. 그러나 0.1에서 5.0까지의 값은 경우에 따라 유용할 수 있습니다.

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

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

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

일반적인 범위를 벗어난 감마 값은 이전 CRT 모니터 또는 산업 환경 또는 창 디스플레이와 같은 비정상적인 조명 조건에 있는 모니터에 유용할 수 있습니다.

적용 대상