Esempio n. 1
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();
        }
Esempio n. 2
0
        /// <summary>
        /// Makes a preview from the file specified and then stores this into the path
        /// specified in thumbPath.
        /// </summary>
        /// <param name="file">File information.</param>
        /// <param name="thumbPath">Preview path.</param>
        /// <returns></returns>
        protected bool makeThumb(FileInfo file, string thumbPath)
        {
            if (!File.Exists(thumbPath) | this.ResetPreviews)
            {
                HttpServerUtility server = HttpContext.Current.Server;

                //get the original pictures
                Bitmap imgIn = new Bitmap(file.FullName);                 // System.Drawing.Image.FromFile(file.FullName);

                //set the format to be the same as the original picture
                System.Drawing.Imaging.ImageFormat format = imgIn.RawFormat;
                System.Drawing.Size newSize = new Size(this.MaxPreviewWidth, this.MaxPreviewHeight);

                System.Drawing.Bitmap imgOut = Amns.GreyFox.Imaging.BitmapTransform.ProportionalResize(imgIn, format, newSize);

                if (watermarkUrl != string.Empty)
                {
                    string watermarkImageUrl = HttpContext.Current.Server.MapPath(watermarkUrl);
                    Bitmap wbmp = new Bitmap(watermarkImageUrl);
                    ImageWatermark.AddWatermark(imgOut, wbmp, watermarkLocation);
                    wbmp.Dispose();
                }

                string borderTop         = mapBorder(borderTopUrl);
                string borderLeft        = mapBorder(borderLeftUrl);
                string borderRight       = mapBorder(borderRightUrl);
                string borderBottom      = mapBorder(borderBottomUrl);
                string borderTopLeft     = mapBorder(borderTopLeftUrl);
                string borderTopRight    = mapBorder(borderTopRightUrl);
                string borderBottomLeft  = mapBorder(borderBottomLeftUrl);
                string borderBottomRight = mapBorder(borderBottomRightUrl);

                BorderFilter borderFilter = new BorderFilter(borderTop, borderLeft, borderRight, borderBottom,
                                                             borderTopLeft, borderTopRight, borderBottomLeft, borderBottomRight);
                borderFilter.ApplyFilter(imgOut);

                Amns.GreyFox.Imaging.ExifProperties.CopyProperties(imgIn, imgOut);

                ImageCodecInfo[] codecArray = ImageCodecInfo.GetImageEncoders();

                EncoderParameter[] parameterArray = new EncoderParameter[1];
                parameterArray[0] = new EncoderParameter(Encoder.Quality, previewQuality);

                EncoderParameters codecParameters = new EncoderParameters();
                codecParameters.Param = parameterArray;

                imgOut.Save(thumbPath, codecArray[1], codecParameters);

                imgIn.Dispose();
                imgOut.Dispose();

                return(true);
            }

            return(false);
        }
Esempio n. 3
0
        private Sf.Filter GetBorderFilter()
        {
            BorderFilter filter = new BorderFilter();

            filter.Fill  = Color.ToFill();
            filter.Width = (int)Value;

            filter.Enabled = true;
            return(filter);
        }
Esempio n. 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();
        }
Esempio n. 5
0
        public mModifyBorder(wColor BorderColor, int Radius)
        {
            Effect = new BorderFilter();

            Fill fill = new Fill();

            fill.BackgroundColor = new mImageColor(BorderColor).ToDynamicColor();

            Effect.Fill    = fill;
            Effect.Width   = Radius;
            Effect.Enabled = true;

            filter = Effect;
        }
Esempio n. 6
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            Composition composition = new Composition();
            var         myLayer     = new ImageLayer();


            myLayer.SourceFileName = Image1.ImageUrl;

            composition.Layers.Add(myLayer);
            //myLayer.Filters.Add(new ResizeFilter { Mode = ResizeMode.UseWidth, Width = SoundInTheory.DynamicImage.Unit.Pixel(1200) });



            if (CheckBox1.Checked)
            {
                myLayer.Filters.Add(new ColorTintFilter());
            }
            if (CheckBox2.Checked)
            {
                Image2.Height = int.Parse(TextBox1.Text);
                Image2.Width  = int.Parse(TextBox2.Text);
            }
            if (CheckBox3.Checked)
            {
                if (DropDownList1.SelectedValue.ToString() == "1")
                {
                    RotationFilter rf = new RotationFilter();
                    rf.Angle = 30;
                    myLayer.Filters.Add(rf);
                }
                else
                {
                    RotationFilter rf = new RotationFilter();
                    rf.Angle = 315;
                    myLayer.Filters.Add(rf);
                }
            }
            if (CheckBox4.Checked)
            {
                myLayer.Filters.Add(new SepiaFilter());
            }
            if (CheckBox5.Checked)
            {
                myLayer.Filters.Add(new EmbossFilter());
            }
            if (CheckBox6.Checked)
            {
                BorderFilter br = new BorderFilter();
                if (DropDownList2.SelectedValue.ToString() == "1")
                {
                    br.Fill.BackgroundColor = Colors.Red;
                }
                if (DropDownList2.SelectedValue.ToString() == "2")
                {
                    br.Fill.BackgroundColor = Colors.Blue;
                }
                if (DropDownList2.SelectedValue.ToString() == "3")
                {
                    br.Fill.BackgroundColor = Colors.Green;
                }
                if (DropDownList2.SelectedValue.ToString() == "4")
                {
                    br.Fill.BackgroundColor = Colors.Black;
                }
                if (DropDownList2.SelectedValue.ToString() == "0")
                {
                    Label7.Visible = true;
                }
                myLayer.Filters.Add(br);
            }



            string url = ImageUrlGenerator.GetImageUrl(composition);

            Image2.ImageUrl = url;
            Image2.Visible  = true;
        }