コード例 #1
0
        public void HighlightsAndShadowsEffectCustomizations()
        {
            const uint D2D1_HIGHLIGHTSANDSHADOWS_INPUT_GAMMA_LINEAR = 0;
            const uint D2D1_HIGHLIGHTSANDSHADOWS_INPUT_GAMMA_SRGB   = 1;

            var effect = new HighlightsAndShadowsEffect();

            // Verify defaults.
            Assert.IsFalse(effect.SourceIsLinearGamma);
            Assert.AreEqual(D2D1_HIGHLIGHTSANDSHADOWS_INPUT_GAMMA_SRGB, EffectAccessor.GetProperty(effect, 3));

            // Change the property, and verify that the boxed value changes to match.
            effect.SourceIsLinearGamma = true;
            Assert.IsTrue(effect.SourceIsLinearGamma);
            Assert.AreEqual(D2D1_HIGHLIGHTSANDSHADOWS_INPUT_GAMMA_LINEAR, EffectAccessor.GetProperty(effect, 3));

            effect.SourceIsLinearGamma = false;
            Assert.IsFalse(effect.SourceIsLinearGamma);
            Assert.AreEqual(D2D1_HIGHLIGHTSANDSHADOWS_INPUT_GAMMA_SRGB, EffectAccessor.GetProperty(effect, 3));

            // Validate that IGraphicsEffectD2D1Interop reports the right customizations.
            int index;
            EffectPropertyMapping mapping;

            EffectAccessor.GetNamedPropertyMapping(effect, "SourceIsLinearGamma", out index, out mapping);
            Assert.AreEqual(3, index);
            Assert.AreEqual(EffectPropertyMapping.Unknown, mapping);
        }
コード例 #2
0
        public CanvasRenderTarget applyHighlightEffects(CanvasBitmap workingBitmap)
        {
            //CanvasBitmap workingBitmap = SelectWorkingBitmap(useOriginalBitmap);

            if (workingBitmap != null)
            {
                int ww = (int)workingBitmap.SizeInPixels.Width;
                int hh = (int)workingBitmap.SizeInPixels.Height;

                HighlightsAndShadowsEffect highlightsAndShadowsEffect = new HighlightsAndShadowsEffect();
                highlightsAndShadowsEffect.Source         = workingBitmap;
                highlightsAndShadowsEffect.Clarity        = (float)highlightClarity;
                highlightsAndShadowsEffect.Shadows        = (float)highlightShadows;
                highlightsAndShadowsEffect.MaskBlurAmount = (float)highlightMaskBlur;
                highlightsAndShadowsEffect.Highlights     = (float)highlightHighlights;

                //if (canvasRenderTarget != null)
                //    canvasRenderTarget.Dispose();
                CanvasRenderTarget canvasRenderTarget = new CanvasRenderTarget(CanvasDevice.GetSharedDevice(), ww, hh, canvasBitmap.Dpi);
                using (var session = canvasRenderTarget.CreateDrawingSession())
                {
                    session.DrawImage(highlightsAndShadowsEffect);
                }

                return(canvasRenderTarget);
            }


            return(null);
        }
コード例 #3
0
 public ICanvasImage ApplyEffect(ICanvasImage source, float value)
 {
     Effect = new HighlightsAndShadowsEffect
     {
         Source = source,
         //s = (float)(value / 500 * 2)
     };
     return(Effect);
 }
コード例 #4
0
        private ICanvasImage CreateHighlightsAndShadows()
        {
            textLabel = requiresWin10;

            var highlightsAndShadowsEffect = new HighlightsAndShadowsEffect
            {
                Source = bitmapTiger
            };

            // Animation adjusts the highlight and shadow levels.
            animationFunction = elapsedTime =>
            {
                highlightsAndShadowsEffect.Highlights = (float)Math.Sin(elapsedTime);
                highlightsAndShadowsEffect.Shadows    = (float)Math.Sin(elapsedTime * 1.3);
                highlightsAndShadowsEffect.Clarity    = (float)Math.Sin(elapsedTime / 7);
            };

            return(highlightsAndShadowsEffect);
        }