Beispiel #1
0
        public void FloydSteinberg1()
        {
            var dt = new FloydSteinbergDither();

            const int xsize = 100;
            const int ysize = 100;

            var b1 = new Bitmap(xsize, ysize);

            b1.SetPixel(50, 50, Color.FromArgb(255, 255, 255, 255));

            var b2 = dt.Process(b1);

            for (int x = 0; x < xsize; x++)
            {
                for (int y = 0; y < ysize; y++)
                {
                    Color col = b2.GetPixel(x, y);

                    if (col.R != 0)
                    {
                        Assert.AreEqual(255, col.R);
                        Assert.AreEqual(255, col.R);
                        Assert.AreEqual(255, col.R);
                        Assert.AreEqual(50, x);
                        Assert.AreEqual(50, y);
                    }
                    else
                    {
                        Assert.AreEqual(0, col.R);
                        Assert.AreEqual(0, col.G);
                        Assert.AreEqual(0, col.B);
                    }
                }
            }
        }
Beispiel #2
0
        public void FloydSteinberg2()
        {
            var dt = new FloydSteinbergDither();

            const int xsize = 100;
            const int ysize = 100;

            var b1 = new Bitmap(xsize, ysize, PixelFormat.Format32bppArgb);

            b1.SetPixel(50, 50, Color.FromArgb(255, 127, 127, 127));
			b1.SetPixel(50, 51, Color.FromArgb(255, 127, 127, 127));
			b1.SetPixel(50, 52, Color.FromArgb(255, 127, 127, 127));
			b1.SetPixel(50, 53, Color.FromArgb(255, 127, 127, 127));

			var b2 = dt.Process(b1);

            for (int x = 0; x < xsize; x++)
            {
                for (int y = 0; y < ysize; y++)
                {
                    Color col = b2.GetPixel(x, y);

                    if (col.R != 0)
                    {
                        Assert.AreEqual(255, col.R);
                        Assert.AreEqual(255, col.R);
                        Assert.AreEqual(255, col.R);
                        Assert.AreEqual(50, x);
                        Assert.IsTrue(y==53 || y==51);
                    }
                    else
                    {
                        Assert.AreEqual(0, col.R);
                        Assert.AreEqual(0, col.G);
                        Assert.AreEqual(0, col.B);
                    }
                }
            }
        }