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; }
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; }