public RawRectangleF[] GetEffectRequiredInputRectangles(ID2D1Effect renderEffect, RectangleF renderImageRectangle, EffectInputDescription[] inputDescriptions)
        {
            var result = new RawRectangleF[inputDescriptions.Length];

            GetEffectRequiredInputRectangles(renderEffect, renderImageRectangle, inputDescriptions, result, inputDescriptions.Length);
            return(result);
        }
Esempio n. 2
0
 /// <summary>
 /// Sets the input by using the output of a given effect.
 /// </summary>
 /// <param name="index">Index of the input</param>
 /// <param name="effect">Effect output to use as input</param>
 /// <param name="invalidate">To invalidate</param>
 public void SetInputEffect(int index, ID2D1Effect effect, bool invalidate = true)
 {
     using (ID2D1Image output = effect.Output)
     {
         SetInput(index, output, invalidate);
     }
 }
Esempio n. 3
0
        public static void DrawImage(this ID2D1DeviceContext context,
                                     ID2D1Effect effect,
                                     D2D1_INTERPOLATION_MODE interpolationMode = D2D1_INTERPOLATION_MODE.D2D1_INTERPOLATION_MODE_LINEAR,
                                     D2D1_COMPOSITE_MODE compositeMode         = D2D1_COMPOSITE_MODE.D2D1_COMPOSITE_MODE_SOURCE_OVER,
                                     D2D_POINT_2F?targetOffset = null,
                                     D2D_RECT_F?imageRectangle = null)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            if (effect == null)
            {
                throw new ArgumentNullException(nameof(effect));
            }

            using (var irc = imageRectangle.StructureToMemory())
            {
                using (var to = targetOffset.StructureToMemory())
                {
                    effect.GetOutput(out var image);
                    try
                    {
                        context.DrawImage(image, to.Pointer, irc.Pointer, interpolationMode, compositeMode);
                    }
                    finally
                    {
                        Marshal.ReleaseComObject(image);
                    }
                }
            }
        }
Esempio n. 4
0
        public static void SetInputCount(this ID2D1Effect effect, int count)
        {
            if (effect == null)
            {
                throw new ArgumentNullException(nameof(effect));
            }

            effect.SetInputCount(count).ThrowOnError();
        }
Esempio n. 5
0
        public static void SetInput(this ID2D1Effect effect, int index, ID2D1Bitmap input = null, bool invalidate = false)
        {
            if (effect == null)
            {
                throw new ArgumentNullException(nameof(effect));
            }

            effect.SetInput(index, input, invalidate);
        }
Esempio n. 6
0
        public static int GetInputCount(this ID2D1Effect effect)
        {
            if (effect == null)
            {
                throw new ArgumentNullException(nameof(effect));
            }

            return(effect.GetInputCount());
        }
 public void DrawImage(
     ID2D1Effect effect,
     InterpolationMode interpolationMode = InterpolationMode.Linear,
     CompositeMode compositeMode         = CompositeMode.SourceOver)
 {
     using (var output = effect.Output)
     {
         DrawImage(output, null, null, interpolationMode, compositeMode);
     }
 }
Esempio n. 8
0
        public static IComObject <ID2D1Image> GetInput(this ID2D1Effect effect, int index)
        {
            if (effect == null)
            {
                throw new ArgumentNullException(nameof(effect));
            }

            effect.GetInput(index, out var image);
            return(new ComObject <ID2D1Image>(image));
        }
        public RawRectangleF[] GetEffectInvalidRectangles(ID2D1Effect effect)
        {
            var invalidRects = new RawRectangleF[GetEffectInvalidRectangleCount(effect)];

            if (invalidRects.Length == 0)
            {
                return(invalidRects);
            }

            GetEffectInvalidRectangles(effect, invalidRects, invalidRects.Length);
            return(invalidRects);
        }
Esempio n. 10
0
        public static void SetInput(this ID2D1Effect effect, ID2D1Image image, int index = 0, bool invalidate = false)
        {
            if (effect == null)
            {
                throw new ArgumentNullException(nameof(effect));
            }

            if (image == null)
            {
                throw new ArgumentNullException(nameof(image));
            }

            effect.SetInput((uint)index, image, invalidate);
        }
Esempio n. 11
0
        public static void SetInputEffect(this ID2D1Effect effect, ID2D1Effect inputEffect, int index = 0, bool invalidate = false)
        {
            if (effect == null)
            {
                throw new ArgumentNullException(nameof(effect));
            }

            if (inputEffect == null)
            {
                throw new ArgumentNullException(nameof(inputEffect));
            }

            inputEffect.GetOutput(out var output);
            effect.SetInput((uint)index, output, invalidate);
            Marshal.ReleaseComObject(output);
        }