ImageAttributes.SetNoOp 方法

定义

关闭颜色调整。

重载

SetNoOp()

为默认类别关闭颜色调整。 可以调用 ClearNoOp 方法恢复在调用 SetNoOp 方法前已存在的颜色调整设置。

SetNoOp(ColorAdjustType)

为指定类别关闭颜色调整。 可以调用 ClearNoOp 方法恢复在调用 SetNoOp 方法前已存在的颜色调整设置。

SetNoOp()

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

为默认类别关闭颜色调整。 可以调用 ClearNoOp 方法恢复在调用 SetNoOp 方法前已存在的颜色调整设置。

public:
 void SetNoOp();
public void SetNoOp ();
member this.SetNoOp : unit -> unit
Public Sub SetNoOp ()

示例

下面的代码示例旨在与 Windows 窗体 一起使用,它需要 PaintEventArgse,它是 事件处理程序的Paint一个参数。 此代码执行以下操作:

  1. 打开使用 Image 文件 Camera.jpg 的 。

  2. 将 对象的伽玛值 ImageAttributes 设置为 0.25。

  3. 将图像绘制到屏幕。

  4. 调用 SetNoOp 方法。

  5. 绘制图像 (第二个相机) 到屏幕;但是,由于 SetNoOp 调用了 方法,因此伽玛设置默认为值 1.0,并且使用默认伽玛设置将图像绘制到屏幕上。

请注意,左侧图像 (0.25) 的伽马非常灰显,右侧图像的对比度更高, (1.0) 的伽玛。

private:
   void SetNoOpExample( PaintEventArgs^ e )
   {
      // Create an Image object from the file Camera.jpg.
      Image^ myImage = Image::FromFile( "Camera.jpg" );

      // Create an ImageAttributes object, and set the gamma to 0.25.
      ImageAttributes^ imageAttr = gcnew ImageAttributes;
      imageAttr->SetGamma( 0.25f );

      // Draw the image with gamma set to 0.25.
      Rectangle rect1 = Rectangle(20,20,200,200);
      e->Graphics->DrawImage( myImage, rect1, 0, 0, 200, 200, GraphicsUnit::Pixel, imageAttr );

      // Call the ImageAttributes NoOp method.
      imageAttr->SetNoOp();

      // Draw the image after NoOp is set, so the default gamma value
      // of 1.0 will be used.
      Rectangle rect2 = Rectangle(250,20,200,200);
      e->Graphics->DrawImage( myImage, rect2, 0, 0, 200, 200, GraphicsUnit::Pixel, imageAttr );
   }
private void SetNoOpExample(PaintEventArgs e)
{
             
    // Create an Image object from the file Camera.jpg.
    Image myImage = Image.FromFile("Camera.jpg");
             
    // Create an ImageAttributes object, and set the gamma to 0.25.
    ImageAttributes imageAttr = new ImageAttributes();
    imageAttr.SetGamma(0.25f);
             
    // Draw the image with gamma set to 0.25.
    Rectangle rect1 = new Rectangle(20, 20, 200, 200);
    e.Graphics.DrawImage(myImage, rect1, 0, 0, 200, 200, 
        GraphicsUnit.Pixel, imageAttr);    
    
    // Call the ImageAttributes NoOp method.
    imageAttr.SetNoOp();
             
    // Draw the image after NoOp is set, so the default gamma value
    // of 1.0 will be used.
    Rectangle rect2 = new Rectangle(250, 20, 200, 200);
    e.Graphics.DrawImage(myImage, rect2, 0, 0, 200, 200, 
        GraphicsUnit.Pixel, imageAttr);    
}
Public Sub SetNoOpExample(ByVal e As PaintEventArgs)

    ' Create an Image object from the file Camera.jpg.
    Dim myImage As Image = Image.FromFile("Camera.jpg")

    ' Create an ImageAttributes object, and set the gamma to 0.25.
    Dim imageAttr As New ImageAttributes
    imageAttr.SetGamma(0.25F)

    ' Draw the image with gamma set to 0.25.
    Dim rect1 As New Rectangle(20, 20, 200, 200)
    e.Graphics.DrawImage(myImage, rect1, 0, 0, 200, 200, _
    GraphicsUnit.Pixel, imageAttr)

    ' Call the ImageAttributes NoOp method.
    imageAttr.SetNoOp()

    ' Draw the image with gamma set to 0.25, but now NoOp is set,    
    ' so the uncorrected image will be shown.
    Dim rect2 As New Rectangle(250, 20, 200, 200)
    e.Graphics.DrawImage(myImage, rect2, 0, 0, 200, 200, _
    GraphicsUnit.Pixel, imageAttr)
    ' Image
End Sub

注解

对象维护五个 ImageAttributes 调整类别的颜色和灰度设置:默认值、位图、画笔、笔和文本。 例如,可以为默认类别指定伽玛值,为位图类别指定不同的伽玛值,并为笔类别指定不同的伽玛值。

默认颜色调整和灰度调整设置适用于没有自己调整设置的所有类别。 例如,如果从未为笔类别指定任何调整设置,默认设置将应用于笔类别。

适用于

SetNoOp(ColorAdjustType)

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

为指定类别关闭颜色调整。 可以调用 ClearNoOp 方法恢复在调用 SetNoOp 方法前已存在的颜色调整设置。

public:
 void SetNoOp(System::Drawing::Imaging::ColorAdjustType type);
public void SetNoOp (System.Drawing.Imaging.ColorAdjustType type);
member this.SetNoOp : System.Drawing.Imaging.ColorAdjustType -> unit
Public Sub SetNoOp (type As ColorAdjustType)

参数

type
ColorAdjustType

ColorAdjustType 的一个元素,指定将关闭颜色校正的类别。

示例

有关代码示例,请参阅 SetNoOp() 方法。

注解

对象维护五个 ImageAttributes 调整类别的颜色和灰度设置:默认值、位图、画笔、笔和文本。 例如,可以为默认类别指定伽玛值,为位图类别指定不同的伽玛值,并为笔类别指定不同的伽玛值。

适用于