Exemple #1
0
        private static Bitmap ApplyDithering(Bitmap image)
        {
            var clone = new Bitmap(image.Width, image.Height, PixelFormat.Format32bppArgb);

            using (var gr = Graphics.FromImage(clone))
            {
                gr.DrawImage(image, new Rectangle(0, 0, clone.Width, clone.Height));
            }

            FloydSteinbergDitherer.Process(clone);
            return(clone);
        }
        /// <summary>
        /// Find the ditherer selected in the combobox
        /// </summary>
        /// <returns>the requested ditherer</returns>
        private IDitherer GetDitherer()
        {
            IDitherer ditherer;

            if (ComboBoxDithererSelection.SelectedIndex == 0)
            {
                ditherer = new FloydSteinbergDitherer();
            }
            else if (ComboBoxDithererSelection.SelectedIndex == 1)
            {
                ditherer = new JarvisJudiceNinkeDitherer();
            }
            else
            {
                throw new Exception("Invalid Ditherer option!");
            }
            return(ditherer);
        }