次の方法で共有


ImageAttributes.SetNoOp メソッド ()

既定のカテゴリのカラー調整をオフにします。ClearNoOp を呼び出して、SetNoOp を呼び出す前のカラー調整設定に戻すことができます。

Overloads Public Sub SetNoOp()
[C#]
public void SetNoOp();
[C++]
public: void SetNoOp();
[JScript]
public function SetNoOp();

戻り値

このメソッドは値を返しません。

解説

ImageAttributes オブジェクトは、5 つの調整カテゴリ (既定、ビットマップ、ブラシ、ペン、テキスト) に関して色とグレースケールの設定を保持します。たとえば、既定のカテゴリに対してあるガンマ値を指定し、ビットマップ カテゴリには別のガンマ値を指定し、さらにペン カテゴリにも異なるガンマ値を指定できます。

既定のカラー調整設定値およびグレースケール調整設定値は、調整設定値が設定されていないすべてのカテゴリに対して適用されます。たとえば、ペン カテゴリの調整設定を一切指定していない場合、ペン カテゴリには既定の設定が適用されます。

使用例

[Visual Basic, C#] 次の例は、Windows フォームでの使用を意図してデザインされており、 Paint イベント ハンドラのパラメータである PaintEventArgs e が必要です。このコードは次のアクションを実行します。

  • ファイル Camera.jpg を使用する Image オブジェクトを開きます。
  • ImageAttributes オブジェクトのガンマ値を 0.25 に設定します。
  • 画面にイメージを描画します。
  • ImageAttributes SetNoOp メソッドを呼び出します。
  • イメージ (2 回目のカメラ) を画面に描画しますが、 SetNoOp メソッドが呼び出されていたため、ガンマ設定は既定値の 1.0 に設定され、既定のガンマ設定でイメージが画面に描画されます。

[Visual Basic, C#] 左側のイメージは強く色あせ (ガンマ 0.25)、右側のイメージの方がコントラストが大きくなっている (ガンマ 1.0) ことに注意してください。

 
Public Sub SetNoOpExample(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
        
[C#] 
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,         // Image
rect1,            // Dest. rect.
0,               // srcX
0,               // srcY
200,             // srcWidth
200,             // srcHeight
GraphicsUnit.Pixel, // srcUnit
imageAttr);      // ImageAttributes
// 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,         // Image
rect2,            // Dest. rect.
0,               // srcX
0,               // srcY
200,             // srcWidth
200,             // srcHeight
GraphicsUnit.Pixel, // srcUnit
imageAttr);      // ImageAttributes
}
        

[C++, JScript] C++ および JScript のサンプルはありません。Visual Basic および C# のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ

参照

ImageAttributes クラス | ImageAttributes メンバ | System.Drawing.Imaging 名前空間 | ImageAttributes.SetNoOp オーバーロードの一覧