//***************************************************************************
        // Static Methods
        //
        private static Bitmap ImgFilter(Bitmap source, float factor, HSLFilterType type)
        {
            int
                width  = source.Width,
                height = source.Height;

            Rectangle rc = new Rectangle(0, 0, width, height);

            if (source.PixelFormat != PixelFormat.Format24bppRgb)
            {
                source = source.Clone(rc, PixelFormat.Format24bppRgb);
            }

            Bitmap dest = new Bitmap(width, height, source.PixelFormat);

            BitmapData dataSrc  = source.LockBits(rc, ImageLockMode.ReadOnly, PixelFormat.Format24bppRgb);
            BitmapData dataDest = dest.LockBits(rc, ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);

            int offset = dataSrc.Stride - (width * 3);

            unsafe
            {
                byte *bytesSrc  = (byte *)(void *)dataSrc.Scan0;
                byte *bytesDest = (byte *)(void *)dataDest.Scan0;
                for (int y = 0; y < height; ++y)
                {
                    for (int x = 0; x < width; ++x)
                    {
                        HSL hsl = HSL.FromRGB(bytesSrc[2], bytesSrc[1], bytesSrc[0]);   // Still BGR (probably due to little-endian byte format.
                        switch (type)
                        {
                        case HSLFilterType.Luminance:
                            hsl.Luminance *= factor;
                            break;

                        case HSLFilterType.Hue:
                            hsl.Hue *= factor;
                            break;

                        case HSLFilterType.Saturation:
                            hsl.Saturation *= factor;
                            break;
                        }

                        Color c = hsl.RGB;

                        bytesDest[0] = c.B;
                        bytesDest[1] = c.G;
                        bytesDest[2] = c.R;

                        bytesSrc  += 3;
                        bytesDest += 3;
                    }
                    bytesDest += offset;
                    bytesSrc  += offset;
                }
                source.UnlockBits(dataSrc);
                dest.UnlockBits(dataDest);
            }
            return(dest);
        }
 //***************************************************************************
 // Static Methods
 //
 public static HSL FromRGB(byte red, byte green, byte blue)
 {
     return(HSL.FromRGB(Color.FromArgb(red, green, blue)));
 }