示例#1
0
        public static void DrawRectangle(Array2DBase image, Rectangle rect, RgbAlphaPixel color, uint thickness = 1)
        {
            if (image == null)
            {
                throw new ArgumentNullException(nameof(image));
            }
            if (rect == null)
            {
                throw new ArgumentNullException(nameof(rect));
            }

            image.ThrowIfDisposed();
            rect.ThrowIfDisposed();
            var ret = Native.draw_rectangle(
                Native.Array2DType.RgbAlphaPixel,
                image.NativePtr,
                rect.NativePtr,
                ref color,
                thickness);

            switch (ret)
            {
            case Native.ErrorType.ArrayTypeNotSupport:
                throw new ArgumentException($"{color} is not supported.");
            }
        }
示例#2
0
        /// <summary>
        /// Adds the given overlay rectangle into this object such that it will be displayed.
        /// </summary>
        /// <param name="rect">A <see cref="DRectangle"/> structure that represents the rectangle to be displayed.</param>
        /// <param name="color">A <see cref="RgbAlphaPixel"/> value that represents a color.</param>
        /// <exception cref="ObjectDisposedException"><see cref="ImageWindow"/> is disposed.</exception>
        public void AddOverlay(DRectangle rect, RgbAlphaPixel color)
        {
            this.ThrowIfDisposed();

            using (var native = rect.ToNative())
                NativeMethods.image_window_add_overlay3(this.NativePtr, native.NativePtr, NativeMethods.Array2DType.RgbAlphaPixel, ref color);
        }
示例#3
0
        public static void DrawLine(Array2DBase image, Point p1, Point p2, RgbAlphaPixel color)
        {
            if (image == null)
            {
                throw new ArgumentNullException(nameof(image));
            }
            if (p1 == null)
            {
                throw new ArgumentNullException(nameof(p1));
            }
            if (p2 == null)
            {
                throw new ArgumentNullException(nameof(p2));
            }

            image.ThrowIfDisposed();
            p1.ThrowIfDisposed();
            p2.ThrowIfDisposed();

            var ret = Native.draw_line(
                Native.Array2DType.RgbAlphaPixel,
                image.NativePtr,
                p1.NativePtr,
                p2.NativePtr,
                ref color);

            switch (ret)
            {
            case Native.ErrorType.ArrayTypeNotSupport:
                throw new ArgumentException($"{color} is not supported.");
            }
        }
示例#4
0
        public void AddOverlay(IEnumerable <Rectangle> rects, RgbAlphaPixel color)
        {
            this.ThrowIfDisposed();

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

            using (var vector = new StdVector <Rectangle>(rects))
                NativeMethods.image_window_add_overlay2(this.NativePtr, vector.NativePtr, NativeMethods.Array2DType.RgbAlphaPixel, ref color);
        }
示例#5
0
        public void AddOverlay(DRectangle rect, RgbAlphaPixel color)
        {
            this.ThrowIfDisposed();

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

            rect.ThrowIfDisposed();

            Native.image_window_add_overlay3(this.NativePtr, rect.NativePtr, Dlib.Native.Array2DType.RgbAlphaPixel, ref color);
        }
示例#6
0
        public void AddOverlay(Rectangle rect, RgbAlphaPixel color, string str)
        {
            if (str == null)
            {
                throw new ArgumentNullException(nameof(str));
            }

            this.ThrowIfDisposed();

            using (var native = rect.ToNative())
                using (var pStr = new StdString(str))
                    NativeMethods.image_window_add_overlay6(this.NativePtr, native.NativePtr, NativeMethods.Array2DType.RgbAlphaPixel, ref color, pStr.NativePtr);
        }
示例#7
0
        public void AddOverlay(IEnumerable <Vector <double> > points, RgbAlphaPixel color)
        {
            this.ThrowIfDisposed();

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

            points.ThrowIfDisposed();

            using (var vector = new StdVector <Vector <double> >(points))
                NativeMethods.perspective_window_add_overlay3(this.NativePtr, vector.NativePtr, NativeMethods.Array2DType.RgbAlphaPixel, ref color);
        }
示例#8
0
        public static void AssignAllPpixels(Array2D <RgbAlphaPixel> dest, RgbAlphaPixel pixel)
        {
            if (dest == null)
            {
                throw new ArgumentNullException(nameof(dest));
            }

            dest.ThrowIfDisposed(nameof(dest));

            var outType = dest.ImageType.ToNativeArray2DType();
            var ret     = Native.assign_all_pixels(outType, dest.NativePtr, Native.Array2DType.RgbAlphaPixel, ref pixel);

            switch (ret)
            {
            case Native.ErrorType.Array2DTypeTypeNotSupport:
                throw new ArgumentException("Output or input type is not supported.");
            }
        }
示例#9
0
        public void AddOverlay(Vector <double> p1, Vector <double> p2, RgbAlphaPixel color)
        {
            this.ThrowIfDisposed();

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

            p1.ThrowIfDisposed();
            p2.ThrowIfDisposed();

            NativeMethods.perspective_window_add_overlay(this.NativePtr, p1.NativePtr, p2.NativePtr, NativeMethods.Array2DType.RgbAlphaPixel, ref color);
        }
示例#10
0
        public static void FillRect(Array2D <RgbAlphaPixel> image, Rectangle rect, RgbAlphaPixel color)
        {
            if (image == null)
            {
                throw new ArgumentNullException(nameof(image));
            }

            image.ThrowIfDisposed();

            using (var native = rect.ToNative())
            {
                var ret = NativeMethods.fill_rect(NativeMethods.Array2DType.RgbAlphaPixel,
                                                  image.NativePtr,
                                                  native.NativePtr,
                                                  ref color);
                switch (ret)
                {
                case NativeMethods.ErrorType.Array2DTypeTypeNotSupport:
                    throw new ArgumentException($"{color} is not supported.");
                }
            }
        }
示例#11
0
 public static extern void matrix_operator_get_row_column_rgb_alpha_pixel(IntPtr matrix, int row, int column, out RgbAlphaPixel ret);
示例#12
0
 public static extern void array2d_set_row_column_rgb_alpha_pixel(IntPtr row, int column, RgbAlphaPixel value);
示例#13
0
 public static extern void image_display_overlay_rect_set_color(IntPtr overlayRect, RgbAlphaPixel color);
示例#14
0
 public static extern void image_display_set_default_overlay_rect_color(IntPtr display, RgbAlphaPixel color);
示例#15
0
 public static void AssignPixel(ref RgbAlphaPixel dest, HsiPixel src)
 {
     NativeMethods.assign_pixel_rgbalpha_hsi(ref dest, ref src);
 }
示例#16
0
 public static extern ErrorType assign_all_pixels(Array2DType out_type, IntPtr out_img, Array2DType in_type, ref RgbAlphaPixel color);
示例#17
0
 public static extern void assign_pixel_rgbalpha_hsi(ref RgbAlphaPixel dest, ref HsiPixel src);
示例#18
0
 public static extern ErrorType draw_rectangle_canvas(IntPtr canvas, IntPtr rect, IntPtr area, Array2DType pixelType, ref RgbAlphaPixel color);
示例#19
0
 public static extern bool image_window_overlay_line_color(IntPtr line, ref RgbAlphaPixel color);
示例#20
0
 public static extern ErrorType draw_line(Array2DType pixelType, IntPtr image, IntPtr p1, IntPtr p2, ref RgbAlphaPixel color);
示例#21
0
 public static extern ErrorType draw_rectangle(Array2DType pixelType, IntPtr image, IntPtr rect, ref RgbAlphaPixel color, uint thickness);
示例#22
0
 public static extern ErrorType perspective_window_add_overlay3(IntPtr window, IntPtr vector, Array2DType type, ref RgbAlphaPixel color);
示例#23
0
 public static extern void matrix_operator_set_row_column_rgb_alpha_pixel(IntPtr matrix, int row, int column, RgbAlphaPixel value);
示例#24
0
 public static extern void assign_pixel_rgbalpha_lab(ref RgbAlphaPixel dest, ref LabPixel src);
示例#25
0
 public static extern ErrorType draw_line_canvas_infinity(IntPtr canvas, IntPtr p1, IntPtr p2, Array2DType pixelType, ref RgbAlphaPixel color);
示例#26
0
        public static void DrawLine(Array2D <RgbAlphaPixel> image, Point p1, Point p2, RgbAlphaPixel color)
        {
            if (image == null)
            {
                throw new ArgumentNullException(nameof(image));
            }
            if (p1 == null)
            {
                throw new ArgumentNullException(nameof(p1));
            }
            if (p2 == null)
            {
                throw new ArgumentNullException(nameof(p2));
            }

            image.ThrowIfDisposed();

            using (var np1 = p1.ToNative())
                using (var np2 = p2.ToNative())
                {
                    var ret = NativeMethods.draw_line(NativeMethods.Array2DType.RgbAlphaPixel,
                                                      image.NativePtr,
                                                      np1.NativePtr,
                                                      np2.NativePtr,
                                                      ref color);
                    switch (ret)
                    {
                    case NativeMethods.ErrorType.Array2DTypeTypeNotSupport:
                        throw new ArgumentException($"{color} is not supported.");
                    }
                }
        }
示例#27
0
 public static extern NativeMethods.ErrorType image_window_add_overlay2(IntPtr window, IntPtr vectorOfRect, NativeMethods.Array2DType type, ref RgbAlphaPixel color);
示例#28
0
 public void SetDefaultOverlayRectColor(RgbAlphaPixel color)
 {
     this.ThrowIfDisposed();
     NativeMethods.image_display_set_default_overlay_rect_color(this.NativePtr, color);
 }
示例#29
0
        public TElement[] ToArray()
        {
            this.ThrowIfDisposed();

            TElement[] result;
            NativeMethods.ErrorType err;

            var templateRows    = this.TemplateRows;
            var templateColumns = this.TemplateColumns;

            switch (this._MatrixElementTypes)
            {
            case MatrixElementTypes.UInt8:
                unsafe
                {
                    var row    = this.Rows;
                    var column = this.Columns;

                    var array = new byte[row * column];
                    fixed(byte *dst = &array[0])
                    {
                        var src  = this.NativePtr;
                        var type = this._ElementType;

                        err = NativeMethods.extensions_matrix_to_array(src, type, templateRows, templateColumns, (IntPtr)dst);
                    }

                    result = array as TElement[];
                }
                break;

            case MatrixElementTypes.UInt16:
                unsafe
                {
                    var row    = this.Rows;
                    var column = this.Columns;

                    var array = new ushort[row * column];
                    fixed(ushort *dst = &array[0])
                    {
                        var src  = this.NativePtr;
                        var type = this._ElementType;

                        err = NativeMethods.extensions_matrix_to_array(src, type, templateRows, templateColumns, (IntPtr)dst);
                    }

                    result = array as TElement[];
                }
                break;

            case MatrixElementTypes.UInt32:
                unsafe
                {
                    var row    = this.Rows;
                    var column = this.Columns;

                    var array = new uint[row * column];
                    fixed(uint *dst = &array[0])
                    {
                        var src  = this.NativePtr;
                        var type = this._ElementType;

                        err = NativeMethods.extensions_matrix_to_array(src, type, templateRows, templateColumns, (IntPtr)dst);
                    }

                    result = array as TElement[];
                }
                break;

            case MatrixElementTypes.Int8:
                unsafe
                {
                    var row    = this.Rows;
                    var column = this.Columns;

                    var array = new sbyte[row * column];
                    fixed(sbyte *dst = &array[0])
                    {
                        var src  = this.NativePtr;
                        var type = this._ElementType;

                        err = NativeMethods.extensions_matrix_to_array(src, type, templateRows, templateColumns, (IntPtr)dst);
                    }

                    result = array as TElement[];
                }
                break;

            case MatrixElementTypes.Int16:
                unsafe
                {
                    var row    = this.Rows;
                    var column = this.Columns;

                    var array = new short[row * column];
                    fixed(short *dst = &array[0])
                    {
                        var src  = this.NativePtr;
                        var type = this._ElementType;

                        err = NativeMethods.extensions_matrix_to_array(src, type, templateRows, templateColumns, (IntPtr)dst);
                    }

                    result = array as TElement[];
                }
                break;

            case MatrixElementTypes.Int32:
                unsafe
                {
                    var row    = this.Rows;
                    var column = this.Columns;

                    var array = new int[row * column];
                    fixed(int *dst = &array[0])
                    {
                        var src  = this.NativePtr;
                        var type = this._ElementType;

                        err = NativeMethods.extensions_matrix_to_array(src, type, templateRows, templateColumns, (IntPtr)dst);
                    }

                    result = array as TElement[];
                }
                break;

            case MatrixElementTypes.Float:
                unsafe
                {
                    var row    = this.Rows;
                    var column = this.Columns;

                    var array = new float[row * column];
                    fixed(float *dst = &array[0])
                    {
                        var src  = this.NativePtr;
                        var type = this._ElementType;

                        err = NativeMethods.extensions_matrix_to_array(src, type, templateRows, templateColumns, (IntPtr)dst);
                    }

                    result = array as TElement[];
                }
                break;

            case MatrixElementTypes.Double:
                unsafe
                {
                    var row    = this.Rows;
                    var column = this.Columns;

                    var array = new double[row * column];
                    fixed(double *dst = &array[0])
                    {
                        var src  = this.NativePtr;
                        var type = this._ElementType;

                        err = NativeMethods.extensions_matrix_to_array(src, type, templateRows, templateColumns, (IntPtr)dst);
                    }

                    result = array as TElement[];
                }
                break;

            case MatrixElementTypes.RgbPixel:
                unsafe
                {
                    var row    = this.Rows;
                    var column = this.Columns;

                    var array = new RgbPixel[row * column];
                    fixed(RgbPixel *dst = &array[0])
                    {
                        var src  = this.NativePtr;
                        var type = this._ElementType;

                        err = NativeMethods.extensions_matrix_to_array(src, type, templateRows, templateColumns, (IntPtr)dst);
                    }

                    result = array as TElement[];
                }
                break;

            case MatrixElementTypes.BgrPixel:
                unsafe
                {
                    var row    = this.Rows;
                    var column = this.Columns;

                    var array = new BgrPixel[row * column];
                    fixed(BgrPixel *dst = &array[0])
                    {
                        var src  = this.NativePtr;
                        var type = this._ElementType;

                        err = NativeMethods.extensions_matrix_to_array(src, type, templateRows, templateColumns, (IntPtr)dst);
                    }

                    result = array as TElement[];
                }
                break;

            case MatrixElementTypes.RgbAlphaPixel:
                unsafe
                {
                    var row    = this.Rows;
                    var column = this.Columns;

                    var array = new RgbAlphaPixel[row * column];
                    fixed(RgbAlphaPixel *dst = &array[0])
                    {
                        var src  = this.NativePtr;
                        var type = this._ElementType;

                        err = NativeMethods.extensions_matrix_to_array(src, type, templateRows, templateColumns, (IntPtr)dst);
                    }

                    result = array as TElement[];
                }
                break;

            case MatrixElementTypes.HsiPixel:
                unsafe
                {
                    var row    = this.Rows;
                    var column = this.Columns;

                    var array = new HsiPixel[row * column];
                    fixed(HsiPixel *dst = &array[0])
                    {
                        var src  = this.NativePtr;
                        var type = this._ElementType;

                        err = NativeMethods.extensions_matrix_to_array(src, type, templateRows, templateColumns, (IntPtr)dst);
                    }

                    result = array as TElement[];
                }
                break;

            case MatrixElementTypes.LabPixel:
                unsafe
                {
                    var row    = this.Rows;
                    var column = this.Columns;

                    var array = new LabPixel[row * column];
                    fixed(LabPixel *dst = &array[0])
                    {
                        var src  = this.NativePtr;
                        var type = this._ElementType;

                        err = NativeMethods.extensions_matrix_to_array(src, type, templateRows, templateColumns, (IntPtr)dst);
                    }

                    result = array as TElement[];
                }
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            switch (err)
            {
            case NativeMethods.ErrorType.MatrixElementTypeNotSupport:
                throw new ArgumentException($"{this._ElementType} is not supported.");

            case NativeMethods.ErrorType.MatrixElementTemplateSizeNotSupport:
                throw new ArgumentException($"{nameof(this.TemplateColumns)} or {nameof(this.TemplateRows)} is not supported.");
            }

            return(result);
        }
示例#30
0
 public static extern IntPtr perspective_window_overlay_dot_new2(IntPtr v, NativeMethods.Array2DType type, ref RgbAlphaPixel color);