ImageAttributes.SetNoOp 方法
定义
关闭颜色调整。Turns off color adjustment.
重载
| SetNoOp(ColorAdjustType) |
为指定类别关闭颜色调整。Turns off color adjustment for a specified category. 可以调用 ClearNoOp 方法恢复在调用 SetNoOp 方法前已存在的颜色调整设置。You can call the ClearNoOp method to reinstate the color-adjustment settings that were in place before the call to the SetNoOp method. |
| SetNoOp() |
为默认类别关闭颜色调整。Turns off color adjustment for the default category. 可以调用 ClearNoOp 方法恢复在调用 SetNoOp 方法前已存在的颜色调整设置。You can call the ClearNoOp method to reinstate the color-adjustment settings that were in place before the call to the SetNoOp method. |
SetNoOp(ColorAdjustType)
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 的一个元素,指定将关闭颜色校正的类别。An element of ColorAdjustType that specifies the category for which color correction is turned off.
示例
有关代码示例,请参见 SetNoOp() 方法。For a code example, see the SetNoOp() method.
注解
ImageAttributes对象维护五个调整类别的颜色和灰度设置:默认值、位图、画笔、笔和文本。An ImageAttributes object maintains color and grayscale settings for five adjustment categories: default, bitmap, brush, pen, and text. 例如,可以为默认类别指定一个伽玛值,为位图类别指定一个不同的伽玛值,并为钢笔类别指定一个伽玛值。For example, you can specify a gamma value for the default category, a different gamma value for the bitmap category, and still a different gamma value for the pen category.
适用于
SetNoOp()
public:
void SetNoOp();
public void SetNoOp ();
member this.SetNoOp : unit -> unit
Public Sub SetNoOp ()
示例
下面的代码示例旨在与 Windows 窗体一起使用,并且它需要作为 PaintEventArgs e Paint 事件处理程序的参数。The following code example is designed for use with Windows Forms, and it requires PaintEventArgse, which is a parameter of the Paint event handler. 此代码执行以下操作:The code performs the following actions:
打开 Image 使用文件 Camera.jpg 的。Opens an Image that uses the file Camera.jpg.
将对象的伽玛值设置 ImageAttributes 为0.25。Sets the gamma value of the ImageAttributes object to 0.25.
将图像绘制到屏幕上。Draws the image to the screen.
在屏幕) (第二个相机上绘制图像;但是,由于 SetNoOp 调用了方法,因此伽玛设置默认为1.0 的值,并且使用默认伽玛设置将图像绘制到屏幕上。Draws the image (a second camera) to the screen; however, because the SetNoOp method was called, the gamma setting defaults to a value of 1.0 and the image is drawn to the screen with the default gamma setting.
请注意,左侧的图像会在 0.25) (伽玛上冲蚀,右侧的图像的对比度 (为 1.0) 伽玛。Note that the image on the left is very washed out (gamma of 0.25) and the image on the right has more contrast (gamma of 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对象维护五个调整类别的颜色和灰度设置:默认值、位图、画笔、笔和文本。An ImageAttributes object maintains color and grayscale settings for five adjustment categories: default, bitmap, brush, pen, and text. 例如,可以为默认类别指定一个伽玛值,为位图类别指定一个不同的伽玛值,并为钢笔类别指定一个伽玛值。For example, you can specify a gamma value for the default category, a different gamma value for the bitmap category, and still a different gamma value for the pen category.
默认颜色调整和灰度调整设置适用于没有自己的调整设置的所有类别。The default color-adjustment and grayscale-adjustment settings apply to all categories that do not have adjustment settings of their own. 例如,如果您从未为 "笔" 类别指定任何调整设置,则默认设置将应用于 "笔" 类别。For example, if you never specify any adjustment settings for the pen category, the default settings apply to the pen category.