ImageAttributes.SetColorKey メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > ImageAttributes.SetColorKey メソッドの意味・解説 

ImageAttributes.SetColorKey メソッド (Color, Color)

既定カテゴリカラー キー設定します

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

Public Sub SetColorKey ( _
    colorLow As Color, _
    colorHigh As Color _
)
Dim instance As ImageAttributes
Dim colorLow As Color
Dim colorHigh As Color

instance.SetColorKey(colorLow, colorHigh)
public void SetColorKey (
    Color colorLow,
    Color colorHigh
)
public:
void SetColorKey (
    Color colorLow, 
    Color colorHigh
)
public void SetColorKey (
    Color colorLow, 
    Color colorHigh
)
public function SetColorKey (
    colorLow : Color, 
    colorHigh : Color
)

パラメータ

colorLow

下位カラー キー値。

colorHigh

上位カラー キー値。

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

解説解説
使用例使用例

コード例については、SetColorKey(Color,Color,ColorAdjustType) メソッドトピック参照してください

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

ImageAttributes.SetColorKey メソッド (Color, Color, ColorAdjustType)

指定したカテゴリカラー キー (透明度範囲) を設定します

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

Public Sub SetColorKey ( _
    colorLow As Color, _
    colorHigh As Color, _
    type As ColorAdjustType _
)
Dim instance As ImageAttributes
Dim colorLow As Color
Dim colorHigh As Color
Dim type As ColorAdjustType

instance.SetColorKey(colorLow, colorHigh, type)
public void SetColorKey (
    Color colorLow,
    Color colorHigh,
    ColorAdjustType type
)
public:
void SetColorKey (
    Color colorLow, 
    Color colorHigh, 
    ColorAdjustType type
)
public void SetColorKey (
    Color colorLow, 
    Color colorHigh, 
    ColorAdjustType type
)
public function SetColorKey (
    colorLow : Color, 
    colorHigh : Color, 
    type : ColorAdjustType
)

パラメータ

colorLow

下位カラー キー値。

colorHigh

上位カラー キー値。

type

カラー キー設定する対象カテゴリ指定する ColorAdjustType の要素

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

解説解説

このメソッドは、透明にする色の範囲指定する上位下位カラー キー値を設定します。色の 3 つの要素 (赤、緑、青) が、それぞれ対応する要素の上位と下位カラー キーの間にある場合、その色は透明になります

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

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

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

使用例使用例

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

  1. ファイル Circle.bmp を使用する Image開き、それを画面描画ます。

  2. ImageAttributes オブジェクト作成しSetColorKey メソッド呼び出すことにより、そのオブジェクトカラー キー設定します

  3. ImageAttributes オブジェクトカラー キー使用してイメージ画面描画ます。

Public Sub SetColorKeyExample(ByVal
 e As PaintEventArgs)

    ' Open an Image file, and draw it to the screen.
    Dim myImage As Image = Image.FromFile("Circle.bmp")
    e.Graphics.DrawImage(myImage, 20, 20)

    ' Create an ImageAttributes object and set the color key.
    Dim lowerColor As Color = Color.FromArgb(245,
 0, 0)
    Dim upperColor As Color = Color.FromArgb(255,
 0, 0)
    Dim imageAttr As New
 ImageAttributes
    imageAttr.SetColorKey(lowerColor, upperColor, _
    ColorAdjustType.Default)

    ' Draw the image with the color key set.
    Dim rect As New Rectangle(150,
 20, 100, 100)
    e.Graphics.DrawImage(myImage, rect, 0, 0, 100, 100, _
    GraphicsUnit.Pixel, imageAttr)
    ' Image
End Sub
private void SetColorKeyExample(PaintEventArgs
 e)
{
             
    // Open an Image file and draw it to the screen.
    Image myImage = Image.FromFile("Circle.bmp");
    e.Graphics.DrawImage(myImage, 20, 20);
             
    // Create an ImageAttributes object and set the color key.
    Color lowerColor = Color.FromArgb(245,0,0);
    Color upperColor = Color.FromArgb(255,0,0);
    ImageAttributes imageAttr = new ImageAttributes();
    imageAttr.SetColorKey(lowerColor,
        upperColor,
        ColorAdjustType.Default);
             
    // Draw the image with the color key set.
    Rectangle rect = new Rectangle(150, 20, 100, 100);
    e.Graphics.DrawImage(myImage, rect, 0, 0, 100, 100, 
        GraphicsUnit.Pixel, imageAttr);      
    
}
private:
   void SetColorKeyExample( PaintEventArgs^ e )
   {
      // Open an Image file and draw it to the screen.
      Image^ myImage = Image::FromFile( "Circle.bmp" );
      e->Graphics->DrawImage( myImage, 20, 20 );

      // Create an ImageAttributes object and set the color key.
      Color lowerColor = Color::FromArgb( 245, 0, 0 );
      Color upperColor = Color::FromArgb( 255, 0, 0 );
      ImageAttributes^ imageAttr = gcnew ImageAttributes;
      imageAttr->SetColorKey( lowerColor, upperColor, ColorAdjustType::Default
 );

      // Draw the image with the color key set.
      Rectangle rect = Rectangle(150,20,100,100);
      e->Graphics->DrawImage( myImage, rect, 0, 0, 100, 100, GraphicsUnit::Pixel,
 imageAttr );
   }
private void SetColorKeyExample(PaintEventArgs
 e)
{
    // Open an Image file and draw it to the screen.
    Image myImage = Image.FromFile("Circle.bmp");

    e.get_Graphics().DrawImage(myImage, 20, 20);

    // Create an ImageAttributes object and set the color key.
    Color lowerColor = Color.FromArgb(245, 0, 0);
    Color upperColor = Color.FromArgb(255, 0, 0);
    ImageAttributes imageAttr = new ImageAttributes();

    imageAttr.SetColorKey(lowerColor, upperColor, ColorAdjustType.Default);

    // Draw the image with the color key set.
    Rectangle rect = new Rectangle(150, 20, 100, 100);

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

ImageAttributes.SetColorKey メソッド

カラー キー (透明度範囲) を設定します
オーバーロードの一覧オーバーロードの一覧

名前 説明
ImageAttributes.SetColorKey (Color, Color) 既定カテゴリカラー キー設定します

.NET Compact Framework によってサポートされています。

ImageAttributes.SetColorKey (Color, Color, ColorAdjustType) 指定したカテゴリカラー キー (透明度範囲) を設定します
参照参照

関連項目

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



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

ImageAttributes.SetColorKey メソッドのお隣キーワード
検索ランキング

   

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



ImageAttributes.SetColorKey メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2025 GRAS Group, Inc.RSS