Beispiel #1
0
        private FREObject Capture(FREContext ctx, uint argc, FREObject[] argv)
        {
            var rect = new WinApi.Rect();

            WinApi.GetWindowRect(_cefWindow, ref rect);
            if (Environment.Is64BitProcess)
            {
                Trace("Capture is not yet available on 64bit Windows.");
                return(FREObject.Zero);
            }
            try {
                var freX = argv[0].AsInt();
                var freY = argv[1].AsInt();
                var freW = argv[2].AsInt();
                var freH = argv[3].AsInt();

                var width  = freW > 0 ? freW : rect.right - rect.left;
                var height = freH > 0 ? freH : rect.bottom - rect.top;

                var bmp      = new Bitmap(width, height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
                var graphics = Graphics.FromImage(bmp);
                graphics.CopyFromScreen(rect.left + freX, rect.top + freY, 0, 0, new Size(width, height),
                                        CopyPixelOperation.SourceCopy);
                var ret = new FreBitmapDataSharp(bmp);
                return(ret.RawValue);
            }
            catch (Exception e) {
                return(new FreException(e).RawValue);
            }
        }
Beispiel #2
0
        private FREObject Capture(FREContext ctx, uint argc, FREObject[] argv)
        {
            var rect = new WinApi.Rect();

            WinApi.GetWindowRect(_cefWindow, ref rect);

            var freX = Convert.ToInt32(new FreObjectSharp(argv[0]).Value);
            var freY = Convert.ToInt32(new FreObjectSharp(argv[1]).Value);
            var freW = Convert.ToInt32(new FreObjectSharp(argv[2]).Value);
            var freH = Convert.ToInt32(new FreObjectSharp(argv[3]).Value);

            var width  = freW > 0 ? freW : rect.right - rect.left;
            var height = freH > 0 ? freW : rect.bottom - rect.top;

            var bmp      = new Bitmap(width, height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
            var graphics = Graphics.FromImage(bmp);

            graphics.CopyFromScreen(rect.left + freX, rect.top + freY, 0, 0, new Size(width, height), CopyPixelOperation.SourceCopy);
            var ret = new FreBitmapDataSharp(bmp);

            return(ret.RawValue);
        }
Beispiel #3
0
        private FREObject Capture(FREContext ctx, uint argc, FREObject[] argv)
        {
            var rect = new WinApi.Rect();

            WinApi.GetWindowRect(_cefWindow, ref rect);
            try {
                var freX = argv[0].AsInt();
                var freY = argv[1].AsInt();
                var freW = argv[2].AsInt();
                var freH = argv[3].AsInt();

                var width  = freW > 0 ? freW : rect.right - rect.left;
                var height = freH > 0 ? freH : rect.bottom - rect.top;

                var bmp      = new Bitmap(width, height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
                var graphics = Graphics.FromImage(bmp);
                graphics.CopyFromScreen(rect.left + freX, rect.top + freY, 0, 0, new Size(width, height),
                                        CopyPixelOperation.SourceCopy);
                return(bmp.ToFREObject());
            }
            catch (Exception e) {
                return(new FreException(e).RawValue);
            }
        }