ImageAttributes.SetThresholdとは? わかりやすく解説

ImageAttributes.SetThreshold メソッド (Single)

既定のカテゴリのしきい値 (透明度の範囲) を指定します。

名前空間: System.Drawing.Imaging
アセンブリ: System.Drawing (system.drawing.dll 内)
構文構文

Public Sub SetThreshold ( _
    threshold As Single _
)
Dim instance As ImageAttributes
Dim threshold As Single

instance.SetThreshold(threshold)
public void SetThreshold (
    float threshold
)
public:
void SetThreshold (
    float threshold
)
public void SetThreshold (
    float threshold
)

パラメータ

threshold

しきい値を指定する実数。

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

解説解説
使用例使用例

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

  1. Image を開き、それを画面に描画します。

  2. ImageAttributes オブジェクトを作成し、SetThreshold メソッドを使用して、そのオブジェクトのしきい値を設定します。

  3. ImageAttributes オブジェクトのしきい値を使用して、イメージを画面に描画します。

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
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
ImageAttributes クラス
ImageAttributes メンバ
System.Drawing.Imaging 名前空間

ImageAttributes.SetThreshold メソッド (Single, ColorAdjustType)

指定したカテゴリのしきい値 (透明度の範囲) を設定します。

名前空間: System.Drawing.Imaging
アセンブリ: System.Drawing (system.drawing.dll 内)
構文構文

Public Sub SetThreshold ( _
    threshold As Single, _
    type As ColorAdjustType _
)
Dim instance As ImageAttributes
Dim threshold As Single
Dim type As ColorAdjustType

instance.SetThreshold(threshold, type)
public void SetThreshold (
    float threshold,
    ColorAdjustType type
)
public:
void SetThreshold (
    float threshold, 
    ColorAdjustType type
)
public void SetThreshold (
    float threshold, 
    ColorAdjustType type
)
public function SetThreshold (
    threshold : float, 
    type : ColorAdjustType
)

パラメータ

threshold

最大値または最小値に変換する色の並べ替えのためのブレークポイントとして使用される、0.0 ~ 1.0 の範囲内のしきい値。

type

色のしきい値を設定する対象のカテゴリを指定する ColorAdjustType の要素。

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

解説解説

しきい値は、色の各要素のカットオフ ポイントを指定する 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 メソッドに渡してペン カテゴリのしきい値を設定すると、ペンには既定の調整設定は一切適用されません。

使用例使用例

コード例については、SetThreshold(Single) メソッドのトピックを参照してください。

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
ImageAttributes クラス
ImageAttributes メンバ
System.Drawing.Imaging 名前空間

ImageAttributes.SetThreshold メソッド

しきい値 (透明度の範囲) を設定します。
オーバーロードの一覧オーバーロードの一覧

名前 説明
ImageAttributes.SetThreshold (Single) 既定のカテゴリのしきい値 (透明度の範囲) を指定します。
ImageAttributes.SetThreshold (Single, ColorAdjustType) 指定したカテゴリのしきい値 (透明度の範囲) を設定します。
参照参照

関連項目

ImageAttributes クラス
ImageAttributes メンバ
System.Drawing.Imaging 名前空間



英和和英テキスト翻訳

英語⇒日本語日本語⇒英語

辞書ショートカット

すべての辞書の索引

「ImageAttributes.SetThreshold」の関連用語

ImageAttributes.SetThresholdのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



ImageAttributes.SetThresholdのページの著作権

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2026 Microsoft.All rights reserved.

©2026 GRAS Group, Inc.RSS