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)

關閉指定分類的彩色調整。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.

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. 例如, 您可以指定預設分類的 gamma 值、點陣圖類別目錄的不同 gamma 值, 以及畫筆分類的 gamma 值。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()

關閉預設分類的色彩調整。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.

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

範例

下列程式碼範例是針對與 Windows Forms 搭配使用所設計, 而且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:

  1. Image開啟使用檔案攝影機的。Opens an Image that uses the file Camera.jpg.

  2. ImageAttributes物件的 gamma 值設定為0.25。Sets the gamma value of the ImageAttributes object to 0.25.

  3. 將影像繪製到螢幕上。Draws the image to the screen.

  4. 呼叫 SetNoOp 方法。Calls the SetNoOp method.

  5. 將影像 (第二張相機) 繪製到螢幕上;不過, 因為已SetNoOp呼叫方法, 所以 gamma 設定會預設為1.0 的值, 而影像則會以預設 gamma 設定繪製到螢幕上。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 的 gamma), 而右邊的影像則具有更高的對比 (1.0 的 gamma)。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. 例如, 您可以指定預設分類的 gamma 值、點陣圖類別目錄的不同 gamma 值, 以及畫筆分類的 gamma 值。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.

適用於