/// <summary>
        /// Take screenshot and save it as PNG image to defined directory
        /// </summary>
        public void takeSnapShot()
        {
            Gdk.Window window = Gdk.Global.DefaultRootWindow;

            if (window != null)
            {
                Gdk.Pixbuf pixBuf = new Gdk.Pixbuf(Gdk.Colorspace.Rgb, false, 8, window.Screen.Width, window.Screen.Height);
                pixBuf.GetFromDrawable(window, Gdk.Colormap.System, 0, 0, 0, 0, window.Screen.Width, window.Screen.Height);

                var now = DateTime.Now;

                // 2012-12-28
                var dayPath = String.Format("{0:0000}-{1:00}-{2:00}", now.Year, now.Month, now.Day);

                // 235911,213
                var fileName = String.Format("{0:00}{1:00}{2:00},{3}", now.Hour, now.Minute, now.Second, now.Millisecond);

                var savePath = settings.directory + "\\" + dayPath;

                if (!Directory.Exists(savePath))
                {
                    // Generate directory
                    Directory.CreateDirectory(savePath);
                }

                savePath += "\\" + fileName + ".png";

                // Save screenshot
                pixBuf.Save(savePath, "png");

                lastFileName = savePath;
            }
        }
        public static byte[] GetScreenshot(int compressionLevel)
        {
            var root = Gdk.Global.DefaultRootWindow;

            int width, height;
            root.GetSize (out width, out height);

            var tmp = new Gdk.Pixbuf (Gdk.Colorspace.Rgb, false, 8, width, height);
            var screenshot = tmp.GetFromDrawable (root, root.Colormap, 0, 0, 0, 0, width, height);

            if (compressionLevel == 0) {
                // return uncompressed
            }
            screenshot.Save ("screen.jpg", "jpeg");
            screenshot.Save ("screen.bmp", "bmp");
            return screenshot.SaveToBuffer ("jpeg");
        }
Beispiel #3
0
        /// <summary>
        /// Take screenshot and save it as PNG image to defined directory
        /// </summary>
        public void takeSnapShot()
        {
            Gdk.Window window = Gdk.Global.DefaultRootWindow;

            if (window != null)
            {
                Gdk.Pixbuf pixBuf = new Gdk.Pixbuf(Gdk.Colorspace.Rgb, false, 8, window.Screen.Width, window.Screen.Height);
                pixBuf.GetFromDrawable(window, Gdk.Colormap.System, 0, 0, 0, 0, window.Screen.Width, window.Screen.Height);

                var now = DateTime.Now;

                // 2012-12-28
                var dayPath = String.Format("{0:0000}-{1:00}-{2:00}", now.Year, now.Month, now.Day);

                // 235911,213
                var fileName = String.Format("{0:00}{1:00}{2:00},{3}", now.Hour, now.Minute, now.Second, now.Millisecond);

                var savePath = settings.directory + "\\" + dayPath;

                if(!Directory.Exists(savePath))
                {
                    // Generate directory
                    Directory.CreateDirectory(savePath);
                }

                savePath += "\\" + fileName + ".png";

                // Save screenshot
                pixBuf.Save(savePath, "png");

                lastFileName = savePath;
            }
        }