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

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

指定したカテゴリのガンマ値を設定します。

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

Public Sub SetGamma ( _
    gamma As Single, _
    type As ColorAdjustType _
)
Dim instance As ImageAttributes
Dim gamma As Single
Dim type As ColorAdjustType

instance.SetGamma(gamma, type)
public void SetGamma (
    float gamma,
    ColorAdjustType type
)
public:
void SetGamma (
    float gamma, 
    ColorAdjustType type
)
public void SetGamma (
    float gamma, 
    ColorAdjustType type
)
public function SetGamma (
    gamma : float, 
    type : ColorAdjustType
)

パラメータ

gamma

ガンマ補正値。

type

ガンマ値を設定する対象のカテゴリを指定する ColorAdjustType の要素。

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

解説解説

gamma パラメータは通常、1.0 ~ 2.2 の範囲の値です。ただし、状況によっては、0.1 ~ 5.0 の値が有効な場合があります。

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

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

特定のカテゴリに対してカラー調整設定値またはグレースケール調整設定値を指定すると、そのカテゴリに適用されていた既定の調整設定値は解除されます。たとえば、既定のカテゴリに対して調整設定値のコレクションを指定するとします。Pen を SetGamma メソッドに渡してペン カテゴリのガンマ値を設定すると、ペンには既定の調整設定は一切適用されません。

旧式の CRT モニタや、特殊な照明環境 (工場やウィンドウ ディスプレイなど) で使用されるモニタなどでは、通常の範囲外のガンマ値を使用した方がよい場合もあります。

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

ImageAttributes.SetGamma メソッド (Single)

既定のカテゴリのガンマ値を設定します。

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

Public Sub SetGamma ( _
    gamma As Single _
)
Dim instance As ImageAttributes
Dim gamma As Single

instance.SetGamma(gamma)
public void SetGamma (
    float gamma
)
public:
void SetGamma (
    float gamma
)
public void SetGamma (
    float gamma
)

パラメータ

gamma

ガンマ補正値。

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

解説解説
使用例使用例

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

  1. ファイル Camera.jpg を使用する Image を開き、ガンマの既定値を使用してそのファイルを画面に描画します。

  2. ImageAttributes オブジェクトを作成し、SetGamma メソッドを呼び出すことにより、そのオブジェクトのガンマを 2.2 に設定します。

  3. ImageAttributes オブジェクト内に設定されたガンマ値を使用して、イメージ (2 回目のカメラ) を画面に描画します。

Public Sub SetGammaExample(ByVal
 e As PaintEventArgs)

    ' Create an Image object from the file Camera.jpg, and draw

    ' it to screen.
    Dim myImage As Image = Image.FromFile("Camera.jpg")
    e.Graphics.DrawImage(myImage, 20, 20)

    ' Create an ImageAttributes object and set the gamma to 2.2.
    Dim imageAttr As New
 ImageAttributes
    imageAttr.SetGamma(2.2F)

    ' Draw the image with gamma set to 2.2.
    Dim rect As New Rectangle(250,
 20, 200, 200)
    e.Graphics.DrawImage(myImage, rect, 0, 0, 200, 200, _
    GraphicsUnit.Pixel, imageAttr)
    ' Image
End Sub
private void SetGammaExample(PaintEventArgs
 e)
{
             
    // Create an Image object from the file Camera.jpg, and draw it
 to
    // the screen.
    Image myImage = Image.FromFile("Camera.jpg");
    e.Graphics.DrawImage(myImage, 20, 20);
             
    // Create an ImageAttributes object and set the gamma to 2.2.
    ImageAttributes imageAttr = new ImageAttributes();
    imageAttr.SetGamma(2.2f);
             
    // Draw the image with gamma set to 2.2.
    Rectangle rect = new Rectangle(250, 20, 200, 200);
    e.Graphics.DrawImage(myImage, rect, 0, 0, 200, 200, 
        GraphicsUnit.Pixel, imageAttr);    
}
private:
   void SetGammaExample( PaintEventArgs^ e )
   {
      // Create an Image object from the file Camera.jpg, and draw it
 to
      // the screen.
      Image^ myImage = Image::FromFile( "Camera.jpg" );
      e->Graphics->DrawImage( myImage, 20, 20 );

      // Create an ImageAttributes object and set the gamma to 2.2.
      ImageAttributes^ imageAttr = gcnew ImageAttributes;
      imageAttr->SetGamma( 2.2f );

      // Draw the image with gamma set to 2.2.
      Rectangle rect = Rectangle(250,20,200,200);
      e->Graphics->DrawImage( myImage, rect, 0, 0, 200, 200, GraphicsUnit::Pixel,
 imageAttr );
   }
private void SetGammaExample(PaintEventArgs
 e)
{
    // Create an Image object from the file Camera.jpg, 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 the gamma to 2.2.
    ImageAttributes imageAttr = new ImageAttributes();

    imageAttr.SetGamma(2.2F);

    // Draw the image with gamma set to 2.2.
    Rectangle rect = new Rectangle(250, 20, 200, 200);

    e.get_Graphics().DrawImage(myImage, rect, 0, 0, 200, 200, 
        GraphicsUnit.Pixel, imageAttr);
} //SetGammaExample
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
ImageAttributes クラス
ImageAttributes メンバ
System.Drawing.Imaging 名前空間

ImageAttributes.SetGamma メソッド

ガンマを設定します。
オーバーロードの一覧オーバーロードの一覧

名前 説明
ImageAttributes.SetGamma (Single) 既定のカテゴリのガンマ値を設定します。
ImageAttributes.SetGamma (Single, ColorAdjustType) 指定したカテゴリのガンマ値を設定します。
参照参照

関連項目

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



英和和英テキスト翻訳

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

辞書ショートカット

すべての辞書の索引

「ImageAttributes.SetGamma」の関連用語

ImageAttributes.SetGammaのお隣キーワード

   

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



ImageAttributes.SetGammaのページの著作権

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

©2026 GRAS Group, Inc.RSS