ImageAttributes.SetThreshold メソッド (Single)
アセンブリ: System.Drawing (system.drawing.dll 内)

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

しきい値は、色の各要素のカットオフ ポイントを指定する 0 ~ 1 の範囲の値です。たとえば、しきい値が 0.7 に設定されているとき、赤、緑、青の要素がそれぞれ 230、50、および 220 である色をレンダリングするとします。赤の要素は 230 で、0.7 × 255 より大きいため、255 (最大輝度) に変更されます。緑の要素は 50 で、0.7 × 255 より小さいため、緑の要素は 0 に変更されます。青の要素は 220 で、0.7 × 255 より大きいため、青の要素は 255 に変更されます。
ImageAttributes オブジェクトは、5 つの調整カテゴリ (既定、ビットマップ、ブラシ、ペン、テキスト) に関して色とグレースケールの設定を保持します。たとえば、既定のカテゴリに対してしきい値を指定し、ビットマップ カテゴリには別のしきい値を指定し、さらにペン カテゴリにも異なるしきい値を指定できます。
既定のカラー調整設定値およびグレースケール調整設定値は、調整設定値が設定されていないすべてのカテゴリに対して適用されます。たとえば、ペン カテゴリの調整設定を一切指定していない場合、ペン カテゴリには既定の設定が適用されます。

次の例は、Windows フォームでの使用を意図してデザインされており、Paint イベント ハンドラのパラメータである PaintEventArgse が必要です。このコードは次のアクションを実行します。
Public Sub SetThresholdExample(ByVal e As PaintEventArgs) ' Open an Image file, and draw it to the screen. Dim myImage As Image = Image.FromFile("Camera.jpg") e.Graphics.DrawImage(myImage, 20, 20) ' Create an ImageAttributes object, and set its color threshold. Dim imageAttr As New ImageAttributes imageAttr.SetThreshold(0.7F) ' Draw the image with the colors bifurcated. Dim rect As New Rectangle(300, 20, 200, 200) e.Graphics.DrawImage(myImage, rect, 0, 0, 200, 200, _ GraphicsUnit.Pixel, imageAttr) End Sub
private void SetThresholdExample(PaintEventArgs e) { // Open an Image file, and draw it to the screen. Image myImage = Image.FromFile("Camera.jpg"); e.Graphics.DrawImage(myImage, 20, 20); // Create an ImageAttributes object, and set its color threshold. ImageAttributes imageAttr = new ImageAttributes(); imageAttr.SetThreshold(0.7f); // Draw the image with the colors bifurcated. Rectangle rect = new Rectangle(300, 20, 200, 200); e.Graphics.DrawImage(myImage, rect, 0, 0, 200, 200, GraphicsUnit.Pixel, imageAttr); }
void SetThresholdExample( PaintEventArgs^ e ) { // Open an Image file, and draw it to the screen. Image^ myImage = Image::FromFile( "Camera.jpg" ); e->Graphics->DrawImage( myImage, 20, 20 ); // Create an ImageAttributes object, and set its color threshold. ImageAttributes^ imageAttr = gcnew ImageAttributes; imageAttr->SetThreshold( 0.7f ); // Draw the image with the colors bifurcated. Rectangle rect = Rectangle(300,20,200,200); e->Graphics->DrawImage( myImage, rect, 0, 0, 200, 200, GraphicsUnit::Pixel, imageAttr ); }
private void SetThresholdExample(PaintEventArgs e) { // Open an Image file, and draw it to the screen. Image myImage = Image.FromFile("Camera.jpg"); e.get_Graphics().DrawImage(myImage, 20, 20); // Create an ImageAttributes object, and set its color threshold. ImageAttributes imageAttr = new ImageAttributes(); imageAttr.SetThreshold(0.7F); // Draw the image with the colors bifurcated. Rectangle rect = new Rectangle(300, 20, 200, 200); e.get_Graphics().DrawImage(myImage, rect, 0, 0, 200, 200, GraphicsUnit.Pixel, imageAttr); } //SetThresholdExample

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


ImageAttributes.SetThreshold メソッド (Single, ColorAdjustType)
アセンブリ: System.Drawing (system.drawing.dll 内)

Dim instance As ImageAttributes Dim threshold As Single Dim type As ColorAdjustType instance.SetThreshold(threshold, type)
戻り値
このメソッドは値を返しません。

しきい値は、色の各要素のカットオフ ポイントを指定する 0 ~ 1 の範囲の値です。たとえば、しきい値が 0.7 に設定されているとき、赤、緑、青の要素がそれぞれ 230、50、および 220 である色をレンダリングするとします。赤の要素は 230 で、0.7 × 255 より大きいため、255 (最大輝度) に変更されます。緑の要素は 50 で、0.7 × 255 より小さいため、緑の要素は 0 に変更されます。青の要素は 220 で、0.7 × 255 より大きいため、青の要素は 255 に変更されます。
ImageAttributes オブジェクトは、5 つの調整カテゴリ (既定、ビットマップ、ブラシ、ペン、テキスト) に関して色とグレースケールの設定を保持します。たとえば、既定のカテゴリに対してしきい値を指定し、ビットマップ カテゴリには別のしきい値を指定し、さらにペン カテゴリにも異なるしきい値を指定できます。
既定のカラー調整設定値およびグレースケール調整設定値は、調整設定値が設定されていないすべてのカテゴリに対して適用されます。たとえば、ペン カテゴリの調整設定を一切指定していない場合、ペン カテゴリには既定の設定が適用されます。
特定のカテゴリに対してカラー調整設定値またはグレースケール調整設定値を指定すると、そのカテゴリに適用されていた既定の調整設定値は解除されます。たとえば、既定のカテゴリに対して調整設定値のコレクションを指定するとします。Pen を SetThreshold メソッドに渡してペン カテゴリのしきい値を設定すると、ペンには既定の調整設定は一切適用されません。


Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


ImageAttributes.SetThreshold メソッド
- ImageAttributes.SetThreshold メソッドのページへのリンク