Example #1
0
        public void rotateTest()
        {
            Bitmap         b    = new Bitmap(10, 10);
            RotateFlipType type = new RotateFlipType(); // TODO: Passenden Wert initialisieren

            RotateFilter.rotate(b, type);
        }
Example #2
0
        private void RotateBT_Click(object sender, EventArgs e)
        {
            if (photoCB.SelectedIndex == -1)
            {
                return;
            }
            if (!float.TryParse(angleTB.Text, out float angle))
            {
                MessageBox.Show("Wrong angle");
                return;
            }
            var rotate = this.Scene.Photos[photoCB.SelectedIndex];

            this.Scene.Photos.Remove(rotate);
            int x = rotate.X, y = rotate.Y;

            rotate = RotateFilter.Process(rotate, angle);
            if (x != rotate.X || y != rotate.Y)
            {
                rotate.ChangeXY(x, y);
            }
            this.Scene.Photos.Insert(photoCB.SelectedIndex, rotate);

            Draw();
        }
Example #3
0
        private void AddBTN_Click(object sender, EventArgs e)
        {
            if (tmp == null)
            {
                return;
            }
            int   w = Int32.Parse(widthInputTB.Text), h = Int32.Parse(heightInputTB.Text);
            float angle = float.Parse(angleInputTB.Text);
            var   insert = ScalingFilter.Process(tmp, w, h);
            int   x = Int32.Parse(xInputTB.Text), y = Int32.Parse(yInputTB.Text);

            if (angle > 1e-10)
            {
                insert = RotateFilter.Process(insert, angle);
            }
            if (insert.X != x || insert.Y != y)
            {
                insert.ChangeXY(x, y);
            }
            this.Scene.Photos.Insert(0, insert);
            this.Scene.UpdatePhotos();

            Draw();
            ListToComboBox(photoCB, this.Scene.Photos);
        }
Example #4
0
        //static void Main(string[] args)
        //{
        //    //GameOfLifeSource golSrc = new GameOfLifeSource(1680, 1050);
        //    GameOfLifeSource golSrc = new GameOfLifeSource(840, 525); // 1680 x 1050 / 2
        //    //GameOfLifeSource golSrc = new GameOfLifeSource(560, 350); // 1680 x 1050 / 3
        //    //GameOfLifeSource golSrc = new GameOfLifeSource(336, 210); // 1680 x 1050 / 5
        //    GenericDelay<Image> delayFilt = new GenericDelay<Image>(new TimeSpan(0, 0, 0, 0, 100));
        //    //WallpaperFilter wpFilt = new WallpaperFilter();
        //    DisplayFilter displayFilt = new DisplayFilter();

        //    golSrc.OutputPin.AttachTo(delayFilt.InputPin);
        //    delayFilt.OutputPin.AttachTo(displayFilt.InputPin);
        //    displayFilt.OutputPin.AttachTo(golSrc.InputPin);

        //    PinOut<Image> golSrcOut = new PinOut<Image>();
        //    golSrcOut.AttachTo(golSrc.InputPin);
        //    golSrcOut.Send(null);
        //    //golSrcOut.Send(null);
        //    //golSrcOut.Send(null);
        //    //golSrcOut.Send(null);
        //    Console.ReadLine();
        //}

        static void Main(string[] args)
        {
            RedditSource          redditSource = new RedditSource("http://www.reddit.com/r/pics/.json");
            GenericFilter <Image> sizeFilt     = new GenericFilter <Image>(img => 100 < img.Width && img.Width < 1000 && 100 < img.Height && img.Height < 800);
            BorderFilter          brdInnerFilt = new BorderFilter(Color.Black, 1);
            BorderFilter          brdOuterFilt = new BorderFilter(Color.White, 9);
            RotateFilter          rotFilt      = new RotateFilter(-30, 30);
            CanvasFilter          cvsFilt      = new CanvasFilter();
            GenericDelay <Image>  delayFilt    = new GenericDelay <Image>(new TimeSpan(0, 0, 30));
            WallpaperFilter       wpFilt       = new WallpaperFilter();

            redditSource.OutputPin.AttachTo(sizeFilt.InputPin);
            sizeFilt.SuccessPin.AttachTo(brdInnerFilt.InputPin);
            sizeFilt.FailurePin.AttachTo(redditSource.InputPin);
            brdInnerFilt.OutputPin.AttachTo(brdOuterFilt.InputPin);
            brdOuterFilt.OutputPin.AttachTo(rotFilt.InputPin);
            rotFilt.OutputPin.AttachTo(cvsFilt.PictureInputPin);
            cvsFilt.OutputPin.AttachTo(delayFilt.InputPin);
            cvsFilt.OutputPin.AttachTo(cvsFilt.CanvasInputPin);
            delayFilt.OutputPin.AttachTo(wpFilt.InputPin);
            wpFilt.OutputPin.AttachTo(redditSource.InputPin);

            /* prime canvas */
            PinOut <Image> canvasOut = new PinOut <Image>();

            canvasOut.AttachTo(cvsFilt.CanvasInputPin);
            Image canvas;

            try
            {
                int          bytesRead;
                byte[]       buf = new byte[1024];
                FileStream   fs  = new FileStream(Path.Combine(Environment.CurrentDirectory, "wall.bmp"), FileMode.Open);
                MemoryStream ms  = new MemoryStream();
                while ((bytesRead = fs.Read(buf, 0, 1024)) > 0)
                {
                    ms.Write(buf, 0, bytesRead);
                }
                ms.Seek(0, SeekOrigin.Begin);
                fs.Close();
                canvas = Image.FromStream(ms);
            }
            catch (FileNotFoundException)
            {
                Size monitorSize = SystemInformation.PrimaryMonitorSize;
                canvas = new Bitmap(monitorSize.Width, monitorSize.Height);
            }
            canvasOut.Send(canvas);

            PinOut <Image> ljSrcOut = new PinOut <Image>();

            ljSrcOut.AttachTo(redditSource.InputPin);
            ljSrcOut.Send(null); /* only need a signal to kick off the source */
            ljSrcOut.Send(null); /* put two images in the loop to test multithreading */
            //ljSrcOut.Send(null); /* hell, why not three? */
            //ljSrcOut.Send(null); /* we are approaching levels of insanity heretofore untold */
            Console.ReadLine();
        }
Example #5
0
        //static void Main(string[] args)
        //{
        //    //GameOfLifeSource golSrc = new GameOfLifeSource(1680, 1050);
        //    GameOfLifeSource golSrc = new GameOfLifeSource(840, 525); // 1680 x 1050 / 2
        //    //GameOfLifeSource golSrc = new GameOfLifeSource(560, 350); // 1680 x 1050 / 3
        //    //GameOfLifeSource golSrc = new GameOfLifeSource(336, 210); // 1680 x 1050 / 5
        //    GenericDelay<Image> delayFilt = new GenericDelay<Image>(new TimeSpan(0, 0, 0, 0, 100));
        //    //WallpaperFilter wpFilt = new WallpaperFilter();
        //    DisplayFilter displayFilt = new DisplayFilter();
        //    golSrc.OutputPin.AttachTo(delayFilt.InputPin);
        //    delayFilt.OutputPin.AttachTo(displayFilt.InputPin);
        //    displayFilt.OutputPin.AttachTo(golSrc.InputPin);
        //    PinOut<Image> golSrcOut = new PinOut<Image>();
        //    golSrcOut.AttachTo(golSrc.InputPin);
        //    golSrcOut.Send(null);
        //    //golSrcOut.Send(null);
        //    //golSrcOut.Send(null);
        //    //golSrcOut.Send(null);
        //    Console.ReadLine();
        //}
        static void Main(string[] args)
        {
            RedditSource redditSource = new RedditSource("http://www.reddit.com/r/pics/.json");
            GenericFilter<Image> sizeFilt = new GenericFilter<Image>(img => 100 < img.Width && img.Width < 1000 && 100 < img.Height && img.Height < 800);
            BorderFilter brdInnerFilt = new BorderFilter(Color.Black, 1);
            BorderFilter brdOuterFilt = new BorderFilter(Color.White, 9);
            RotateFilter rotFilt = new RotateFilter(-30, 30);
            CanvasFilter cvsFilt = new CanvasFilter();
            GenericDelay<Image> delayFilt = new GenericDelay<Image>(new TimeSpan(0, 0, 30));
            WallpaperFilter wpFilt = new WallpaperFilter();

            redditSource.OutputPin.AttachTo(sizeFilt.InputPin);
            sizeFilt.SuccessPin.AttachTo(brdInnerFilt.InputPin);
            sizeFilt.FailurePin.AttachTo(redditSource.InputPin);
            brdInnerFilt.OutputPin.AttachTo(brdOuterFilt.InputPin);
            brdOuterFilt.OutputPin.AttachTo(rotFilt.InputPin);
            rotFilt.OutputPin.AttachTo(cvsFilt.PictureInputPin);
            cvsFilt.OutputPin.AttachTo(delayFilt.InputPin);
            cvsFilt.OutputPin.AttachTo(cvsFilt.CanvasInputPin);
            delayFilt.OutputPin.AttachTo(wpFilt.InputPin);
            wpFilt.OutputPin.AttachTo(redditSource.InputPin);

            /* prime canvas */
            PinOut<Image> canvasOut = new PinOut<Image>();
            canvasOut.AttachTo(cvsFilt.CanvasInputPin);
            Image canvas;
            try
            {
                int bytesRead;
                byte[] buf = new byte[1024];
                FileStream fs = new FileStream(Path.Combine(Environment.CurrentDirectory, "wall.bmp"), FileMode.Open);
                MemoryStream ms = new MemoryStream();
                while ((bytesRead = fs.Read(buf, 0, 1024)) > 0)
                    ms.Write(buf, 0, bytesRead);
                ms.Seek(0, SeekOrigin.Begin);
                fs.Close();
                canvas = Image.FromStream(ms);
            }
            catch (FileNotFoundException)
            {
                Size monitorSize = SystemInformation.PrimaryMonitorSize;
                canvas = new Bitmap(monitorSize.Width, monitorSize.Height);
            }
            canvasOut.Send(canvas);

            PinOut<Image> ljSrcOut = new PinOut<Image>();
            ljSrcOut.AttachTo(redditSource.InputPin);
            ljSrcOut.Send(null); /* only need a signal to kick off the source */
            ljSrcOut.Send(null); /* put two images in the loop to test multithreading */
            //ljSrcOut.Send(null); /* hell, why not three? */
            //ljSrcOut.Send(null); /* we are approaching levels of insanity heretofore untold */
            Console.ReadLine();
        }
Example #6
0
 public void RotateFilterConstructorTest()
 {
     RotateFilter target = new RotateFilter();
 }