void DemandCreateBloomRenderTarget(ICanvasAnimatedControl sender) { float w = (float)sender.Size.Width; float h = (float)sender.Size.Height; // Early-out if we already have a rendertarget of the correct size. // Compare sizes as pixels rather than dips to avoid rounding artifacts. if (bloomRenderTarget != null && bloomRenderTarget.SizeInPixels.Width == sender.ConvertDipsToPixels(w) && bloomRenderTarget.SizeInPixels.Height == sender.ConvertDipsToPixels(h)) { return; } // Destroy the old rendertarget. if (bloomRenderTarget != null) { bloomRenderTarget.Dispose(); } // Create the new rendertarget. bloomRenderTarget = new CanvasRenderTarget(sender, w, h); // Configure the bloom effect to use this new rendertarget. extractBrightAreas.Source = bloomRenderTarget; bloomResult.Background = bloomRenderTarget; }
int DipsToPixelSize(ICanvasAnimatedControl sender, float dips) { System.Diagnostics.Debug.Assert(dips > 0); return Math.Max(sender.ConvertDipsToPixels(dips, CanvasDpiRounding.Round), 1); }
int DipsToPixelSize(ICanvasAnimatedControl sender, float dips) { System.Diagnostics.Debug.Assert(dips > 0); return(Math.Max(sender.ConvertDipsToPixels(dips, CanvasDpiRounding.Round), 1)); }