ColorMatrix 생성자

정의

ColorMatrix 클래스의 새 인스턴스를 초기화합니다.

오버로드

ColorMatrix()

ColorMatrix 클래스의 새 인스턴스를 초기화합니다.

ColorMatrix(ReadOnlySpan<Single>)
ColorMatrix(Single[][])

지정된 newColorMatrix 매트릭스의 요소를 사용하여 ColorMatrix 클래스의 새 인스턴스를 초기화합니다.

ColorMatrix()

Source:
ColorMatrix.cs
Source:
ColorMatrix.cs
Source:
ColorMatrix.cs

ColorMatrix 클래스의 새 인스턴스를 초기화합니다.

public:
 ColorMatrix();
public ColorMatrix ();
Public Sub New ()

적용 대상

ColorMatrix(ReadOnlySpan<Single>)

Source:
ColorMatrix.cs
public:
 ColorMatrix(ReadOnlySpan<float> newColorMatrix);
public ColorMatrix (ReadOnlySpan<float> newColorMatrix);
new System.Drawing.Imaging.ColorMatrix : ReadOnlySpan<single> -> System.Drawing.Imaging.ColorMatrix
Public Sub New (newColorMatrix As ReadOnlySpan(Of Single))

매개 변수

newColorMatrix
ReadOnlySpan<Single>

적용 대상

ColorMatrix(Single[][])

Source:
ColorMatrix.cs
Source:
ColorMatrix.cs
Source:
ColorMatrix.cs

중요

이 API는 CLS 규격이 아닙니다.

지정된 newColorMatrix 매트릭스의 요소를 사용하여 ColorMatrix 클래스의 새 인스턴스를 초기화합니다.

public:
 ColorMatrix(cli::array <cli::array <float> ^> ^ newColorMatrix);
[System.CLSCompliant(false)]
public ColorMatrix (float[][] newColorMatrix);
[<System.CLSCompliant(false)>]
new System.Drawing.Imaging.ColorMatrix : single[][] -> System.Drawing.Imaging.ColorMatrix
Public Sub New (newColorMatrix As Single()())

매개 변수

newColorMatrix
Single[][]

ColorMatrix의 요소 값입니다.

특성

예제

다음 코드 예제를 생성 하 고 사용 하는 방법을 보여 줍니다.ColorMatrix 이 예제를 실행하려면 코드를 Windows Form에 붙여넣고 양식의 Paint 이벤트 처리 메서드에서 를 로 RotateColors 전달 ePaintEventArgs합니다.

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);
}
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

적용 대상