public Gif Rainbow(Bitmap b, IMessage m) { Vector3[,] HSVimage = new Vector3[b.Width, b.Height]; int[,] Alphas = new int[b.Width, b.Height]; using (UnsafeBitmapContext c = ImageExtensions.CreateUnsafeContext(b)) for (int x = 0; x < b.Width; x++) { for (int y = 0; y < b.Height; y++) { Color col = c.GetPixel(x, y); Alphas[x, y] = col.A; HSVimage[x, y] = new Vector3(col.GetHue(), col.GetSaturation(), col.GetValue()); } } int steps = 20; int stepWidth = 360 / steps; Bitmap[] re = new Bitmap[steps]; for (int i = 0; i < steps; i++) { re[i] = new Bitmap(b.Width, b.Height); using UnsafeBitmapContext c = ImageExtensions.CreateUnsafeContext(re[i]); for (int x = 0; x < b.Width; x++) { for (int y = 0; y < b.Height; y++) { c.SetPixel(x, y, Color.FromArgb(Alphas[x, y], HSVimage[x, y].HsvToRgb())); HSVimage[x, y].X += stepWidth; while (HSVimage[x, y].X > 360) { HSVimage[x, y].X -= 360; } } } } return(new Gif(re, Enumerable.Repeat(33, re.Length).ToArray())); }