Пример #1
0
        public unsafe void DrawBitmapLattice(SKBitmap bitmap, SKLattice lattice, SKRect dst, SKPaint paint = null)
        {
            if (bitmap == null)
            {
                throw new ArgumentNullException(nameof(bitmap));
            }
            if (lattice.XDivs == null)
            {
                throw new ArgumentNullException(nameof(lattice.XDivs));
            }
            if (lattice.YDivs == null)
            {
                throw new ArgumentNullException(nameof(lattice.YDivs));

                fixed(int *x = lattice.XDivs)
                fixed(int *y             = lattice.YDivs)
                fixed(SKLatticeFlags * f = lattice.Flags)
                {
                    var nativeLattice = new SKLatticeInternal {
                        fBounds = null,
                        fFlags  = f,
                        fXCount = lattice.XDivs.Length,
                        fXDivs  = x,
                        fYCount = lattice.YDivs.Length,
                        fYDivs  = y,
                    };

                    if (lattice.Bounds != null)
                    {
                        var bounds = lattice.Bounds.Value;
                        nativeLattice.fBounds = &bounds;
                    }
                    SkiaApi.sk_canvas_draw_bitmap_lattice(Handle, bitmap.Handle, ref nativeLattice, ref dst, paint == null ? IntPtr.Zero : paint.Handle);
                }
        }
Пример #2
0
        public void DrawImageLattice(SKImage image, SKLattice lattice, SKRect dst, SKPaint paint = null)
        {
            if (image == null)
            {
                throw new ArgumentNullException(nameof(image));
            }
            if (lattice.XDivs == null)
            {
                throw new ArgumentNullException(nameof(lattice.XDivs));
            }
            if (lattice.YDivs == null)
            {
                throw new ArgumentNullException(nameof(lattice.YDivs));
            }

            unsafe
            {
                fixed(int *x = lattice.XDivs)
                fixed(int *y = lattice.YDivs)
                fixed(SKLatticeRectType * r = lattice.RectTypes)
                fixed(SKColor * c           = lattice.Colors)
                {
                    var nativeLattice = new SKLatticeInternal {
                        fBounds    = null,
                        fRectTypes = r,
                        fXCount    = lattice.XDivs.Length,
                        fXDivs     = x,
                        fYCount    = lattice.YDivs.Length,
                        fYDivs     = y,
                        fColors    = c,
                    };

                    if (lattice.Bounds != null)
                    {
                        var bounds = lattice.Bounds.Value;
                        nativeLattice.fBounds = &bounds;
                    }
                    SkiaApi.sk_canvas_draw_image_lattice(Handle, image.Handle, ref nativeLattice, ref dst, paint == null ? IntPtr.Zero : paint.Handle);
                }
            }
        }
Пример #3
0
        public unsafe void DrawImageLattice(SKImage image, SKLattice lattice, SKRect dst, SKPaint paint = null)
        {
            if (image == null)
            {
                throw new ArgumentNullException(nameof(image));
            }
            if (lattice.XDivs == null)
            {
                throw new ArgumentNullException(nameof(lattice.XDivs));
            }
            if (lattice.YDivs == null)
            {
                throw new ArgumentNullException(nameof(lattice.YDivs));
            }

            unsafe
            {
                fixed(int *x = &lattice.XDivs[0])
                fixed(int *y             = &lattice.YDivs[0])
                fixed(SKLatticeFlags * f = &lattice.Flags[0])
                {
                    var nativeLattice = new SKLatticeInternal {
                        fBounds = null,
                        fFlags  = f,
                        fXCount = lattice.XDivs.Length,
                        fXDivs  = x,
                        fYCount = lattice.YDivs.Length,
                        fYDivs  = y,
                    };

                    if (lattice.Bounds != null)
                    {
                        var bounds = lattice.Bounds.Value;
                        nativeLattice.fBounds = &bounds;
                    }
                    SkiaApi.sk_canvas_draw_image_lattice(Handle, image.Handle, ref nativeLattice, ref dst, paint == null ? IntPtr.Zero : paint.Handle);
                }
            }
        }
Пример #4
0
        public void DrawBitmapLattice(SKBitmap bitmap, SKLattice lattice, SKRect dst, SKPaint paint = null)
        {
            if (bitmap == null)
            {
                throw new ArgumentNullException(nameof(bitmap));
            }
            if (lattice.XDivs == null)
            {
                throw new ArgumentNullException(nameof(lattice.XDivs));
            }
            if (lattice.YDivs == null)
            {
                throw new ArgumentNullException(nameof(lattice.YDivs));

                fixed(int *x = lattice.XDivs)
                fixed(int *y = lattice.YDivs)
                fixed(SKLatticeRectType * r = lattice.RectTypes)
                fixed(SKColor * c           = lattice.Colors)
                {
                    var nativeLattice = new SKLatticeInternal {
                        fBounds    = null,
                        fRectTypes = r,
                        fXCount    = lattice.XDivs.Length,
                        fXDivs     = x,
                        fYCount    = lattice.YDivs.Length,
                        fYDivs     = y,
                        fColors    = (uint *)c,
                    };

                    if (lattice.Bounds != null)
                    {
                        var bounds = lattice.Bounds.Value;
                        nativeLattice.fBounds = &bounds;
                    }
                    SkiaApi.sk_canvas_draw_bitmap_lattice(Handle, bitmap.Handle, &nativeLattice, &dst, paint == null ? IntPtr.Zero : paint.Handle);
                }
        }