示例#1
0
        /// <summary>
        /// Draws the given frame to the video.
        /// </summary>
        /// <param name="device">The device on which the given framebuffer is created.</param>
        /// <param name="uploadedTexture">The texture which should be added to the video.</param>
        public void DrawFrame(EngineDevice device, MemoryMappedTexture <int> uploadedTexture)
        {
            try
            {
                device.EnsureNotNull(nameof(device));
                uploadedTexture.EnsureNotNull(nameof(uploadedTexture));
                if (!_hasStarted)
                {
                    throw new SeeingSharpGraphicsException($"{nameof(SeeingSharpVideoWriter)} is not started!");
                }
                if (_hasFinished)
                {
                    throw new SeeingSharpGraphicsException($"{nameof(SeeingSharpVideoWriter)} has already finished before!");
                }

                // Check for correct image size
                if (_videoSize != uploadedTexture.PixelSize)
                {
                    throw new SeeingSharpGraphicsException("Size has changed during recording!");
                }

                this.DrawFrameInternal(device, uploadedTexture);
            }
            catch (Exception ex)
            {
                _drawException = ex;
            }
        }
示例#2
0
        /// <summary>
        /// Gets the bitmap for the given device..
        /// </summary>
        /// <param name="engineDevice">The engine device.</param>
        internal override D2D.ID2D1Bitmap GetBitmap(EngineDevice engineDevice)
        {
            // Check for disposed state
            if (this.IsDisposed)
            {
                throw new ObjectDisposedException(this.GetType().Name);
            }
            GraphicsCore.EnsureGraphicsSupportLoaded();

            var result = _loadedBitmaps[engineDevice.DeviceIndex];

            if (result == null)
            {
                using var mapped = new MemoryMappedTexture <int>(_bitmapSize);

                // Load the bitmap initially
                result = engineDevice.FakeRenderTarget2D !.CreateBitmap(
                    new Size(_bitmapSize.Width, _bitmapSize.Height),
                    mapped.Pointer, mapped.Width * 4,
                    new D2D.BitmapProperties(_pixelFormat, (float)_dpiX, (float)_dpiY));
                _loadedBitmaps[engineDevice.DeviceIndex] = result;
                engineDevice.RegisterDeviceResource(this);
            }

            return(result);
        }
示例#3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="StandardTextureResource" /> class.
        /// </summary>
        internal StandardTextureResource(MemoryMappedTexture <int> inMemoryTexture)
        {
            inMemoryTexture.EnsureNotNull(nameof(inMemoryTexture));

            _inMemoryTexture = inMemoryTexture;
        }
示例#4
0
 /// <summary>
 /// Draws the given frame to the video.
 /// </summary>
 /// <param name="device">The device on which the given framebuffer is created.</param>
 /// <param name="uploadedTexture">The texture which should be added to the video.</param>
 protected abstract void DrawFrameInternal(EngineDevice device, MemoryMappedTexture <int> uploadedTexture);