Exemplo n.º 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);
                    }
                }
            }
        }
Exemplo n.º 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);
                }
            }
        }
Exemplo n.º 3
0
 public static void DrawBitmap(this IComObject <ID2D1DeviceContext> context,
                               IComObject <ID2D1Bitmap> bitmap,
                               float opacity = 1,
                               D2D1_INTERPOLATION_MODE interpolationMode = D2D1_INTERPOLATION_MODE.D2D1_INTERPOLATION_MODE_NEAREST_NEIGHBOR,
                               D2D_RECT_F?destinationRectangle           = null,
                               D2D_RECT_F?sourceRectangle            = null,
                               D2D_MATRIX_4X4_F?perspectiveTransform = null) => DrawBitmap(context?.Object, bitmap?.Object, opacity, interpolationMode, destinationRectangle, sourceRectangle, perspectiveTransform);
Exemplo n.º 4
0
        public virtual void SetInterpolationMode1(
            D2D1_INTERPOLATION_MODE interpolationMode
            )
        {
            var fp = GetFunctionPointer(16);

            if (m_SetInterpolationMode1Func == null)
            {
                m_SetInterpolationMode1Func = (SetInterpolationMode1Func)Marshal.GetDelegateForFunctionPointer(fp, typeof(SetInterpolationMode1Func));
            }

            m_SetInterpolationMode1Func(m_ptr, interpolationMode);
        }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
0
        public virtual void DrawBitmap(
            ID2D1Bitmap bitmap,
            ref System.Numerics.Vector4 destinationRectangle,
            float opacity,
            D2D1_INTERPOLATION_MODE interpolationMode,
            ref System.Numerics.Vector4 sourceRectangle,
            ref D2D_MATRIX_4X4_F perspectiveTransform
            )
        {
            var fp = GetFunctionPointer(85);

            if (m_DrawBitmapFunc == null)
            {
                m_DrawBitmapFunc = (DrawBitmapFunc)Marshal.GetDelegateForFunctionPointer(fp, typeof(DrawBitmapFunc));
            }

            m_DrawBitmapFunc(m_ptr, bitmap != null ? bitmap.Ptr : IntPtr.Zero, ref destinationRectangle, opacity, interpolationMode, ref sourceRectangle, ref perspectiveTransform);
        }
Exemplo n.º 7
0
        public static void DrawBitmap(this ID2D1DeviceContext context,
                                      ID2D1Bitmap bitmap,
                                      float opacity = 1,
                                      D2D1_INTERPOLATION_MODE interpolationMode = D2D1_INTERPOLATION_MODE.D2D1_INTERPOLATION_MODE_NEAREST_NEIGHBOR,
                                      D2D_RECT_F?destinationRectangle           = null,
                                      D2D_RECT_F?sourceRectangle            = null,
                                      D2D_MATRIX_4X4_F?perspectiveTransform = null)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

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

            using (var drc = destinationRectangle.StructureToMemory())
            {
                using (var src = sourceRectangle.StructureToMemory())
                {
                    if (perspectiveTransform.HasValue || (int)interpolationMode > (int)D2D1_BITMAP_INTERPOLATION_MODE.D2D1_BITMAP_INTERPOLATION_MODE_LINEAR)
                    {
                        using (var per = perspectiveTransform.StructureToMemory())
                        {
                            context.DrawBitmap(bitmap, drc.Pointer, opacity, interpolationMode, src.Pointer, per.Pointer);
                        }
                    }
                    else
                    {
                        context.DrawBitmap(bitmap, drc.Pointer, opacity, (D2D1_BITMAP_INTERPOLATION_MODE)interpolationMode, src.Pointer);
                    }
                }
            }
        }
Exemplo n.º 8
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));
 }
Exemplo n.º 9
0
 public int DrawBitmap(ID2D1Bitmap *bitmap, [NativeTypeName("const D2D1_RECT_F *")] D2D_RECT_F *destinationRectangle, [NativeTypeName("FLOAT")] float opacity, D2D1_INTERPOLATION_MODE interpolationMode, [NativeTypeName("const D2D1_RECT_F *")] D2D_RECT_F *sourceRectangle, [NativeTypeName("const D2D1_MATRIX_4X4_F *")] D2D_MATRIX_4X4_F *perspectiveTransform)
 {
     return(((delegate * unmanaged <ID2D1CommandSink1 *, ID2D1Bitmap *, D2D_RECT_F *, float, D2D1_INTERPOLATION_MODE, D2D_RECT_F *, D2D_MATRIX_4X4_F *, int>)(lpVtbl[17]))((ID2D1CommandSink1 *)Unsafe.AsPointer(ref this), bitmap, destinationRectangle, opacity, interpolationMode, sourceRectangle, perspectiveTransform));
 }
 public D2D1_BITMAP_BRUSH_PROPERTIES1(D2D1_EXTEND_MODE extendModeX = D2D1_EXTEND_MODE_CLAMP, D2D1_EXTEND_MODE extendModeY = D2D1_EXTEND_MODE_CLAMP, D2D1_INTERPOLATION_MODE interpolationMode = D2D1_INTERPOLATION_MODE_LINEAR)
 {
     this = BitmapBrushProperties1(extendModeX, extendModeY, interpolationMode);
 }
Exemplo n.º 11
0
 public HRESULT BlendImage(ID2D1Image *image, D2D1_BLEND_MODE blendMode, [NativeTypeName("const D2D1_POINT_2F *")] D2D_POINT_2F *targetOffset, [NativeTypeName("const D2D1_RECT_F *")] D2D_RECT_F *imageRectangle, D2D1_INTERPOLATION_MODE interpolationMode)
 {
     return(((delegate * unmanaged <ID2D1CommandSink5 *, ID2D1Image *, D2D1_BLEND_MODE, D2D_POINT_2F *, D2D_RECT_F *, D2D1_INTERPOLATION_MODE, int>)(lpVtbl[34]))((ID2D1CommandSink5 *)Unsafe.AsPointer(ref this), image, blendMode, targetOffset, imageRectangle, interpolationMode));
 }
 public void SetInterpolationMode(D2D1_INTERPOLATION_MODE interpolationMode)
 {
     ((delegate * stdcall <ID2D1ImageBrush *, D2D1_INTERPOLATION_MODE, void>)(lpVtbl[11]))((ID2D1ImageBrush *)Unsafe.AsPointer(ref this), interpolationMode);
 }
 public void SetInterpolationMode1(D2D1_INTERPOLATION_MODE interpolationMode)
 {
     ((delegate * stdcall <ID2D1BitmapBrush1 *, D2D1_INTERPOLATION_MODE, void>)(lpVtbl[16]))((ID2D1BitmapBrush1 *)Unsafe.AsPointer(ref this), interpolationMode);
 }
Exemplo n.º 14
0
 public D2D1_IMAGE_BRUSH_PROPERTIES([NativeTypeName("D2D1_RECT_F")] D2D_RECT_F sourceRectangle, D2D1_EXTEND_MODE extendModeX = D2D1_EXTEND_MODE_CLAMP, D2D1_EXTEND_MODE extendModeY = D2D1_EXTEND_MODE_CLAMP, D2D1_INTERPOLATION_MODE interpolationMode = D2D1_INTERPOLATION_MODE_LINEAR)
 {
     this = ImageBrushProperties(sourceRectangle, extendModeX, extendModeY, interpolationMode);
 }
Exemplo n.º 15
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);