ARCed.Core.QColorMatrix.ToColorMatrix C# (CSharp) Method

ToColorMatrix() public method

Converts the matrix to a ColorMatrix and returns it.
public ToColorMatrix ( ) : System.Drawing.Imaging.ColorMatrix
return System.Drawing.Imaging.ColorMatrix
        public ColorMatrix ToColorMatrix()
        {
            var cm = new ColorMatrix();
            for (int i = 0; i < MATRIX_LENGTH; i++)
            {
                for (int j = 0; j < MATRIX_LENGTH; j++)
                {
                    cm[i, j] = this._matrix[i, j];
                }
            }
            return cm;
        }

Usage Example

Beispiel #1
0
 /// <summary>
 /// Rotates the hue of an image
 /// </summary>
 /// <param name="image">Image to change</param>
 /// <param name="hue">Degree of hue displacement (0..360)</param>
 /// <remarks>Values out of range will be automatically corrected</remarks>
 public static void RotateHue(Image image, int hue)
 {
     using (var newImage = new Bitmap(image))
     {
         using (var g = Graphics.FromImage(image))
         {
             var imageAttr = new ImageAttributes();
             var qm = new QColorMatrix();
             qm.RotateHue(hue % 360);
             imageAttr.SetColorMatrix(qm.ToColorMatrix());
             var destRect = new Rectangle(new Point(), image.Size);
             g.Clear(Color.Transparent);
             g.DrawImage(newImage, destRect, 0, 0, image.Width, image.Height,
                 GraphicsUnit.Pixel, imageAttr);
         }
     }
 }
All Usage Examples Of ARCed.Core.QColorMatrix::ToColorMatrix