Beispiel #1
0
        public void Perform()
        {
            if (_states.SelectionRequest != null)
            {
                _render.Camera = _states.Camera.Clone() as Camera;
                _render.Draw(_renderContext, _states.Cell, _states.SimParams);

                IntPtr data;
                int    width, height, pitch;
                _rtAspect.Lock(out data, out width, out height, out pitch);
                try
                {
                    KeyValuePair <int, int> coords = _states.MouseLocalCoordinates;
                    int mouseX = Math.Max(0, Math.Min(coords.Key, width - 1));
                    int mouseY = Math.Max(0, Math.Min(coords.Value, height - 1));

                    unsafe
                    {
                        int color = *((int *)data + mouseX + mouseY * pitch / 4);
                        _context.SelectedObject = _stAspect.DecodeColor(_states.Cell, new SlimDX.Color4(color));
                    }
                }
                finally
                { _rtAspect.UnLock(); }
            }
        }
Beispiel #2
0
        public void Perform()
        {
            if (_states.VideoCaptureRequest != null)
            {
                if (_context.VideoSaver.IsCapturing)
                {
                    _context.VideoSaver.Stop();
                }
                else
                {
                    _context.VideoSaver.Start();
                }
            }

            if (_states.ScreenshotRequest != null)
            {
                _render.Camera = _states.Camera;
                _render.Draw(_imageRenderContext, _states.Cell, _states.SimParams);

                IntPtr data;
                int    width, height, pitch;
                _imageRttAspect.Lock(out data, out width, out height, out pitch);
                try
                { _context.ImageSaver.Save(data, width, height, pitch, PixelFormat.Format32bppArgb); }
                finally
                { _imageRttAspect.UnLock(); }
            }

            if (_context.VideoSaver.IsCapturing)
            {
                _render.Camera = _states.Camera;
                _render.Draw(_videoRenderContext, _states.Cell, _states.SimParams);

                IntPtr data;
                int    width, height, pitch;
                _videoRttAspect.Lock(out data, out width, out height, out pitch);
                try
                { _context.VideoSaver.SetFrame(data, width, height, pitch, PixelFormat.Format32bppArgb); }
                finally
                { _videoRttAspect.UnLock(); }
            }
        }