Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("en-US");
            Thread.CurrentThread.CurrentCulture     = new CultureInfo("en-US");
            var       screen = Screen.PrimaryScreen;
            Rectangle bounds = screen.Bounds;
            Bitmap    result;

            //on exit event for default wallpaper setup
            _handler += OnProcessExiting;
            SetConsoleCtrlHandler(_handler, true);

            defaultWallpaper = GetPathOfWallpaper();
            // string fullPath;
            while (true)
            {
                using (result = new Bitmap(bounds.Width, bounds.Height))
                {
                    using (Graphics g = Graphics.FromImage(result))
                    {
                        g.CopyFromScreen(Screen.PrimaryScreen.Bounds.Location, Point.Empty, bounds.Size);
                    }
                    var gaussianBlur = new SuperfastBlur.GaussianBlur(result);
                    var final_result = gaussianBlur.Process(20);
                    final_result.Save(Path.GetTempPath() + "test.jpg", ImageFormat.Jpeg);
                }
                // fullPath = Path.GetFullPath(imageFileName);
                DisplayPicture(imageFileName);
                Thread.Sleep(300);
            }
        }
Ejemplo n.º 2
0
        public override void Render(Graphics globalGraphics, float scaleFactor)
        {
            var img = new Bitmap((int)globalGraphics.VisibleClipBounds.Width, (int)globalGraphics.VisibleClipBounds.Height, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);

            using (var g = Graphics.FromImage(img))
            {
                base.Render(g, scaleFactor);
            }
            SuperfastBlur.GaussianBlur blur = new SuperfastBlur.GaussianBlur(img);
            globalGraphics.DrawImage(blur.Process((int)(BlurRadius * scaleFactor)), new PointF(0, 0));
        }
Ejemplo n.º 3
0
 public static Stream GetCurrentArtworkBlur()
 {
     using (Image img = Image.FromStream(GetCurrentArtwork()))
     {
         using (Bitmap b = new Bitmap(img, new Size(100, 100)))
         {
             var    blur         = new SuperfastBlur.GaussianBlur(b);
             var    blurredImage = blur.Process(10);
             byte[] bin;
             using (MemoryStream ms2 = new MemoryStream())
             {
                 blurredImage.Save(ms2, System.Drawing.Imaging.ImageFormat.Jpeg);
                 bin = ms2.ToArray();
             }
             return(new MemoryStream(bin));
         }
     }
 }
Ejemplo n.º 4
0
        public static void Blur(string path, int radiusMin, int radiusMax)
        {
            PreProcessing(path);
            MagickImage sourceImg = new MagickImage(path);
            var         image     = Image.FromFile(path);
            var         blur      = new SuperfastBlur.GaussianBlur(image as Bitmap);
            Random      rand      = new Random();
            int         blurRad   = rand.Next(radiusMin, radiusMax + 1);

            Program.Print("-> Using blur radius " + blurRad);
            var    result   = blur.Process(blurRad);
            string tempPath = Path.Combine(IOUtils.GetAppDataDir(), "blur-out.png");

            result.Save(tempPath, ImageFormat.Png);
            result.Dispose();
            image.Dispose();
            MagickImage outImg = new MagickImage(tempPath);

            outImg.Format = sourceImg.Format;
            outImg.Write(path);
            PostProcessing(null, path, path);
        }