Beispiel #1
0
 private void RenderPixel(D2D.RenderTarget rt, PreviewPixel p, D2D.SolidColorBrush brush)
 {
     //if (p.PixelSize <= 4)
     //rt.DrawLine(new D2D.Point2F(p.X, p.Y), new D2D.Point2F(p.X + 1, p.Y + 1), brush, p.PixelSize);
     //else
     //rt.FillEllipse(new D2D.Ellipse() { Point = new D2D.Point2F(p.X, p.Y), RadiusX = p.PixelSize / 2, RadiusY = p.PixelSize / 2 }, brush);
 }
Beispiel #2
0
        private void CreateRenderTarget(DirectX.Graphics.Surface surface)
        {
            // Create a D2D render target which can draw into our offscreen D3D
            // surface. D2D uses device independant units, like WPF, at 96/inch
            var properties = new D2D.RenderTargetProperties();

            properties.DpiX     = 96f;
            properties.DpiY     = 96f;
            properties.MinLevel = DirectX.Direct3D.FeatureLevel.Default;
            //properties.PixelFormat = new D2D.PixelFormat(DirectX.Graphics.Format.Unknown, D2D.AlphaMode.Premultiplied);

            // Changed by Ayush
            properties.PixelFormat = new D2D.PixelFormat(DirectX.Graphics.Format.B8G8R8A8UNorm, D2D.AlphaMode.Premultiplied);

            properties.RenderTargetType = D2D.RenderTargetType.Default;
            properties.Usage            = D2D.RenderTargetUsages.None;

            // Assign result to temporary variable in case CreateGraphicsSurfaceRenderTarget throws
            var target = this.factory.CreateGraphicsSurfaceRenderTarget(surface, properties);

            if (this.renderTarget != null)
            {
                this.renderTarget.Dispose();
            }
            this.renderTarget = target;
        }
Beispiel #3
0
        /// <summary>
        /// Releases the DirectX device and any device dependent resources.
        /// </summary>
        /// <remarks>
        /// This method is safe to be called even if the instance has been disposed.
        /// </remarks>
        public void FreeResources()
        {
            this.OnFreeResources();

            if (this.texture != null)
            {
                this.texture.Dispose();
                this.texture = null;
            }
            if (this.renderTarget != null)
            {
                this.renderTarget.Dispose();
                this.renderTarget = null;
            }
            if (this.device != null)
            {
                this.device.Dispose();
                this.device = null;
            }
        }
Beispiel #4
0
        private void CreateRenderTarget(DirectX.Graphics.Surface surface)
        {
            // Create a D2D render target which can draw into our offscreen D3D
            // surface. D2D uses device independant units, like WPF, at 96/inch
            var properties = new D2D.RenderTargetProperties();
            properties.DpiX = 96;
            properties.DpiY = 96;
            properties.MinLevel = DirectX.Direct3D.FeatureLevel.Default;
            properties.PixelFormat = new D2D.PixelFormat(DirectX.Graphics.Format.Unknown, D2D.AlphaMode.Premultiplied);
            properties.RenderTargetType = D2D.RenderTargetType.Default;
            properties.Usage = D2D.RenderTargetUsages.None;

            // Assign result to temporary variable in case CreateGraphicsSurfaceRenderTarget throws
            var target = this.factory.CreateGraphicsSurfaceRenderTarget(surface, properties);

            if (this.renderTarget != null)
            {
                this.renderTarget.Dispose();
            }
            this.renderTarget = target;
        }
Beispiel #5
0
        /// <summary>
        /// Releases the DirectX device and any device dependent resources.
        /// </summary>
        /// <remarks>
        /// This method is safe to be called even if the instance has been disposed.
        /// </remarks>
        public void FreeResources()
        {
            this.OnFreeResources();

            if (this.texture != null)
            {
                this.texture.Dispose();
                this.texture = null;
            }
            if (this.renderTarget != null)
            {
                this.renderTarget.Dispose();
                this.renderTarget = null;
            }
            if (this.device != null)
            {
                this.device.Dispose();
                this.device = null;
            }
        }