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

RotateHue() public method

Rotate the hue around the gray axis, keeping luminance fixed. Grays are fixed, all other colors change.
public RotateHue ( float phi ) : void
phi float Degrees to rotate
return void
        public void RotateHue(float phi)
        {
            InitHue();
            this.Multiply(_preHue, MatrixOrder.MatrixOrderAppend);
            this.RotateBlue(phi, MatrixOrder.MatrixOrderAppend);
            this.Multiply(_postHue, MatrixOrder.MatrixOrderAppend);
        }

Usage Example

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