ColorMatrixとは? わかりやすく解説

ColorMatrix クラス

RGBA 空間の座標を格納する 5 × 5 の行列を定義します。ImageAttributes クラスのいくつかのメソッドは、カラー行列を使用してイメージの色を調整します。このクラスは継承できません。

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

Public NotInheritable Class
 ColorMatrix
public sealed class ColorMatrix
public ref class ColorMatrix sealed
public final class ColorMatrix
解説解説

行列係数は、ARGB 同次値の変換に使用される 5 × 5 の線形変換です。たとえば、アルファ、赤、緑、青、および w (w は常に 1) で表現される ARGB ベクタなどです。

継承階層継承階層
System.Object
  System.Drawing.Imaging.ColorMatrix
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバの場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
ColorMatrix メンバ
System.Drawing.Imaging 名前空間

ColorMatrix コンストラクタ ()


ColorMatrix コンストラクタ (Single[][])

指定した行列 newColorMatrix の要素を使用して、ColorMatrix クラスの新しいインスタンスを初期化します。

このコンストラクタは、CLS に準拠していません。  

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

<CLSCompliantAttribute(False)> _
Public Sub New ( _
    newColorMatrix As Single()() _
)
Dim newColorMatrix As Single()()

Dim instance As New ColorMatrix(newColorMatrix)
[CLSCompliantAttribute(false)] 
public ColorMatrix (
    float[][] newColorMatrix
)
[CLSCompliantAttribute(false)] 
public:
ColorMatrix (
    array<array<float>^>^ newColorMatrix
)
/** @attribute CLSCompliantAttribute(false) */ 
public ColorMatrix (
    float[][] newColorMatrix
)
CLSCompliantAttribute(false) 
public function ColorMatrix (
    newColorMatrix : float[][]
)

パラメータ

newColorMatrix

新しい ColorMatrix の要素の値。

使用例使用例

ColorMatrix を作成して使用する方法を次のコード例で示します。この例を実行するには、コードを Windows フォームに貼り付け、フォームの Paint イベント処理メソッドから、e を PaintEventArgs として渡すことにより、RotateColors を呼び出します。

Private Sub RotateColors(ByVal
 e As PaintEventArgs)
    Dim image As Bitmap = New
 Bitmap("RotationInput.bmp")
    Dim imageAttributes As New
 ImageAttributes()
    Dim width As Integer
 = image.Width
    Dim height As Integer
 = image.Height
    Dim degrees As Single
 = 60.0F
    Dim r As Double = degrees
 * System.Math.PI / 180 ' degrees to radians
    Dim colorMatrixElements As Single()()
 = { _
       New Single() {CSng(System.Math.Cos(r)),
 _
                     CSng(System.Math.Sin(r)), 0, 0, 0}, _
       New Single() {CSng(-System.Math.Sin(r)),
 _
                     CSng(-System.Math.Cos(r)), 0, 0, 0}, _
       New Single() {0, 0, 2, 0, 0}, _
       New Single() {0, 0, 0, 1, 0}, _
       New Single() {0, 0, 0, 0, 1}}

    Dim colorMatrix As New
 ColorMatrix(colorMatrixElements)

    imageAttributes.SetColorMatrix( _
       colorMatrix, _
       ColorMatrixFlag.Default, _
       ColorAdjustType.Bitmap)

    e.Graphics.DrawImage(image, 10, 10, width, height)

    ' Pass in the destination rectangle (2nd argument), the upper-left
 corner 
    ' (3rd and 4th arguments), width (5th argument),  and height (6th
 
    ' argument) of the source rectangle.
    e.Graphics.DrawImage( _
       image, _
       New Rectangle(150, 10, width, height), _
       0, 0, _
       width, _
       height, _
       GraphicsUnit.Pixel, _
       imageAttributes)
End Sub
private void RotateColors(PaintEventArgs e)
{
    Bitmap image = new Bitmap("RotationInput.bmp");
    ImageAttributes imageAttributes = new ImageAttributes();
    int width = image.Width;
    int height = image.Height;
    float degrees = 60f;
    double r = degrees * System.Math.PI / 180; // degrees to radians

    float[][] colorMatrixElements = { 
        new float[] {(float)System.Math.Cos(r),
  (float)System.Math.Sin(r),  0,  0, 0},
        new float[] {(float)-System.Math.Sin(r),
  (float)-System.Math.Cos(r),  0,  0, 0},
        new float[] {0,  0,  2,  0, 0},
        new float[] {0,  0,  0,  1, 0},
        new float[] {0, 0, 0, 0, 1}};

    ColorMatrix colorMatrix = new ColorMatrix(colorMatrixElements);

    imageAttributes.SetColorMatrix(
       colorMatrix,
       ColorMatrixFlag.Default,
       ColorAdjustType.Bitmap);

    e.Graphics.DrawImage(image, 10, 10, width, height);

    e.Graphics.DrawImage(
       image,
       new Rectangle(150, 10, width, height),  //
 destination rectangle 
        0, 0,        // upper-left corner of source rectangle 
        width,       // width of source rectangle
        height,      // height of source rectangle
        GraphicsUnit.Pixel,
       imageAttributes);

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

ColorMatrix コンストラクタ

ColorMatrix クラスの新しいインスタンスを初期化します。
オーバーロードの一覧オーバーロードの一覧

名前 説明
ColorMatrix () ColorMatrix クラスの新しいインスタンスを初期化します。
ColorMatrix (Single[][]) 指定した行列 newColorMatrix の要素を使用して、ColorMatrix クラスの新しいインスタンスを初期化します。
参照参照

関連項目

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

ColorMatrix プロパティ


パブリック プロパティパブリック プロパティ

  名前 説明
パブリック プロパティ Item ColorMatrix で指定された行と列にある要素を取得または設定します。
パブリック プロパティ Matrix00 この ColorMatrix の第 0 (ゼロ) 行、第 0 列にある要素を取得または設定します。
パブリック プロパティ Matrix01 この ColorMatrix の第 0 (ゼロ) 行、第 1 列にある要素を取得または設定します。
パブリック プロパティ Matrix02 この ColorMatrix の第 0 (ゼロ) 行、第 2 列にある要素を取得または設定します。
パブリック プロパティ Matrix03 この ColorMatrix の第 0 (ゼロ) 行、第 3 列にある要素を取得または設定します。
パブリック プロパティ Matrix04 この ColorMatrix の第 0 (ゼロ) 行、第 4 列にある要素を取得または設定します。
パブリック プロパティ Matrix10 この ColorMatrix の第 1 行、第 0 (ゼロ) 列にある要素を取得または設定します。
パブリック プロパティ Matrix11 この ColorMatrix の第 1 行、第 1 列にある要素を取得または設定します。
パブリック プロパティ Matrix12 この ColorMatrix の第 1 行、第 2 列にある要素を取得または設定します。
パブリック プロパティ Matrix13 この ColorMatrix の第 1 行、第 3 列にある要素を取得または設定します。
パブリック プロパティ Matrix14 この ColorMatrix の第 1 行、第 4 列にある要素を取得または設定します。
パブリック プロパティ Matrix20 この ColorMatrix の第 2 行、第 0 (ゼロ) 列にある要素を取得または設定します。
パブリック プロパティ Matrix21 この ColorMatrix の第 2 行、第 1 列にある要素を取得または設定します。
パブリック プロパティ Matrix22 この ColorMatrix の第 2 行、第 2 列にある要素を取得または設定します。
パブリック プロパティ Matrix23 この ColorMatrix の第 2 行、第 3 列にある要素を取得または設定します。
パブリック プロパティ Matrix24 この ColorMatrix の第 2 行、第 4 列にある要素を取得または設定します。
パブリック プロパティ Matrix30 この ColorMatrix の第 3 行、第 0 (ゼロ) 列にある要素を取得または設定します。
パブリック プロパティ Matrix31 この ColorMatrix の第 3 行、第 1 列にある要素を取得または設定します。
パブリック プロパティ Matrix32 この ColorMatrix の第 3 行、第 2 列にある要素を取得または設定します。
パブリック プロパティ Matrix33 この ColorMatrix の第 3 行、第 3 列にある要素を取得または設定します。
パブリック プロパティ Matrix34 この ColorMatrix の第 3 行、第 4 列にある要素を取得または設定します。
パブリック プロパティ Matrix40 この ColorMatrix の第 4 行、第 0 (ゼロ) 列にある要素を取得または設定します。
パブリック プロパティ Matrix41 この ColorMatrix の第 4 行、第 1 列にある要素を取得または設定します。
パブリック プロパティ Matrix42 この ColorMatrix の第 4 行、第 2 列にある要素を取得または設定します。
パブリック プロパティ Matrix43 この ColorMatrix の第 4 行、第 3 列にある要素を取得または設定します。
パブリック プロパティ Matrix44 この ColorMatrix の第 4 行、第 4 列にある要素を取得または設定します。
参照参照

関連項目

ColorMatrix クラス
System.Drawing.Imaging 名前空間

ColorMatrix メソッド


ColorMatrix メンバ

RGBA 空間の座標を格納する 5 × 5 の行列を定義します。ImageAttributes クラスのいくつかのメソッドは、カラー行列を使用してイメージの色を調整します。このクラスは継承できません。

ColorMatrix データ型で公開されるメンバを以下の表に示します。


パブリック コンストラクタパブリック コンストラクタ
パブリック プロパティパブリック プロパティ
  名前 説明
パブリック プロパティ Item ColorMatrix で指定された行と列にある要素を取得または設定します。
パブリック プロパティ Matrix00 この ColorMatrix の第 0 (ゼロ) 行、第 0 列にある要素を取得または設定します。
パブリック プロパティ Matrix01 この ColorMatrix の第 0 (ゼロ) 行、第 1 列にある要素を取得または設定します。
パブリック プロパティ Matrix02 この ColorMatrix の第 0 (ゼロ) 行、第 2 列にある要素を取得または設定します。
パブリック プロパティ Matrix03 この ColorMatrix の第 0 (ゼロ) 行、第 3 列にある要素を取得または設定します。
パブリック プロパティ Matrix04 この ColorMatrix の第 0 (ゼロ) 行、第 4 列にある要素を取得または設定します。
パブリック プロパティ Matrix10 この ColorMatrix の第 1 行、第 0 (ゼロ) 列にある要素を取得または設定します。
パブリック プロパティ Matrix11 この ColorMatrix の第 1 行、第 1 列にある要素を取得または設定します。
パブリック プロパティ Matrix12 この ColorMatrix の第 1 行、第 2 列にある要素を取得または設定します。
パブリック プロパティ Matrix13 この ColorMatrix の第 1 行、第 3 列にある要素を取得または設定します。
パブリック プロパティ Matrix14 この ColorMatrix の第 1 行、第 4 列にある要素を取得または設定します。
パブリック プロパティ Matrix20 この ColorMatrix の第 2 行、第 0 (ゼロ) 列にある要素を取得または設定します。
パブリック プロパティ Matrix21 この ColorMatrix の第 2 行、第 1 列にある要素を取得または設定します。
パブリック プロパティ Matrix22 この ColorMatrix の第 2 行、第 2 列にある要素を取得または設定します。
パブリック プロパティ Matrix23 この ColorMatrix の第 2 行、第 3 列にある要素を取得または設定します。
パブリック プロパティ Matrix24 この ColorMatrix の第 2 行、第 4 列にある要素を取得または設定します。
パブリック プロパティ Matrix30 この ColorMatrix の第 3 行、第 0 (ゼロ) 列にある要素を取得または設定します。
パブリック プロパティ Matrix31 この ColorMatrix の第 3 行、第 1 列にある要素を取得または設定します。
パブリック プロパティ Matrix32 この ColorMatrix の第 3 行、第 2 列にある要素を取得または設定します。
パブリック プロパティ Matrix33 この ColorMatrix の第 3 行、第 3 列にある要素を取得または設定します。
パブリック プロパティ Matrix34 この ColorMatrix の第 3 行、第 4 列にある要素を取得または設定します。
パブリック プロパティ Matrix40 この ColorMatrix の第 4 行、第 0 (ゼロ) 列にある要素を取得または設定します。
パブリック プロパティ Matrix41 この ColorMatrix の第 4 行、第 1 列にある要素を取得または設定します。
パブリック プロパティ Matrix42 この ColorMatrix の第 4 行、第 2 列にある要素を取得または設定します。
パブリック プロパティ Matrix43 この ColorMatrix の第 4 行、第 3 列にある要素を取得または設定します。
パブリック プロパティ Matrix44 この ColorMatrix の第 4 行、第 4 列にある要素を取得または設定します。
パブリック メソッドパブリック メソッド
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

ColorMatrix クラス
System.Drawing.Imaging 名前空間



英和和英テキスト翻訳

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

辞書ショートカット

すべての辞書の索引

「ColorMatrix」の関連用語

ColorMatrixのお隣キーワード
検索ランキング

   

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



ColorMatrixのページの著作権

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

©2026 GRAS Group, Inc.RSS