예제 #1
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);
                    }
                }
            }
        }
예제 #2
0
        public static void DrawImage(this ID2D1DeviceContext context,
                                     ID2D1Image image,
                                     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 (image == null)
            {
                throw new ArgumentNullException(nameof(image));
            }

            using (var irc = imageRectangle.StructureToMemory())
            {
                using (var to = targetOffset.StructureToMemory())
                {
                    context.DrawImage(image, to.Pointer, irc.Pointer, interpolationMode, compositeMode);
                }
            }
        }
예제 #3
0
        public virtual void DrawImage(
            ID2D1Image image,
            ref System.Numerics.Vector2 targetOffset,
            ref System.Numerics.Vector4 imageRectangle,
            D2D1_INTERPOLATION_MODE interpolationMode,
            D2D1_COMPOSITE_MODE compositeMode
            )
        {
            var fp = GetFunctionPointer(83);

            if (m_DrawImageFunc == null)
            {
                m_DrawImageFunc = (DrawImageFunc)Marshal.GetDelegateForFunctionPointer(fp, typeof(DrawImageFunc));
            }

            m_DrawImageFunc(m_ptr, image != null ? image.Ptr : IntPtr.Zero, ref targetOffset, ref imageRectangle, interpolationMode, compositeMode);
        }
예제 #4
0
 public int DrawImage(ID2D1Image *image, [NativeTypeName("const D2D1_POINT_2F *")] D2D_POINT_2F *targetOffset, [NativeTypeName("const D2D1_RECT_F *")] D2D_RECT_F *imageRectangle, D2D1_INTERPOLATION_MODE interpolationMode, D2D1_COMPOSITE_MODE compositeMode)
 {
     return(((delegate * unmanaged <ID2D1CommandSink1 *, ID2D1Image *, D2D_POINT_2F *, D2D_RECT_F *, D2D1_INTERPOLATION_MODE, D2D1_COMPOSITE_MODE, int>)(lpVtbl[18]))((ID2D1CommandSink1 *)Unsafe.AsPointer(ref this), image, targetOffset, imageRectangle, interpolationMode, compositeMode));
 }
 public int SetMode(D2D1_COMPOSITE_MODE mode)
 {
     return(((delegate * unmanaged <IDCompositionCompositeEffect *, D2D1_COMPOSITE_MODE, int>)(lpVtbl[4]))((IDCompositionCompositeEffect *)Unsafe.AsPointer(ref this), mode));
 }
예제 #6
0
 public static void DrawImage(this IComObject <ID2D1DeviceContext> context,
                              IComObject <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) => DrawImage(context?.Object, effect?.Object, interpolationMode, compositeMode, targetOffset, imageRectangle);