Exemplo n.º 1
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="LabPixel"/> value that represents a color.</param>
        /// <exception cref="ObjectDisposedException"><see cref="ImageWindow"/> is disposed.</exception>
        public void AddOverlay(DRectangle rect, LabPixel color)
        {
            this.ThrowIfDisposed();

            using (var native = rect.ToNative())
                NativeMethods.image_window_add_overlay3(this.NativePtr, native.NativePtr, NativeMethods.Array2DType.LabPixel, ref color);
        }
Exemplo n.º 2
0
        public void AddOverlay(IEnumerable <Rectangle> rects, LabPixel 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.LabPixel, ref color);
        }
Exemplo n.º 3
0
        public void AddOverlay(Rectangle rect, LabPixel 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.LabPixel, ref color, pStr.NativePtr);
        }
Exemplo n.º 4
0
        public void AddOverlay(IEnumerable <Vector <double> > points, LabPixel 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.LabPixel, ref color);
        }
Exemplo n.º 5
0
        public void AddOverlay(Vector <double> p1, Vector <double> p2, LabPixel 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.LabPixel, ref color);
        }
Exemplo n.º 6
0
        public static void AssignAllPixels(Array2D <LabPixel> dest, LabPixel pixel)
        {
            if (dest == null)
            {
                throw new ArgumentNullException(nameof(dest));
            }

            dest.ThrowIfDisposed(nameof(dest));

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

            switch (ret)
            {
            case NativeMethods.ErrorType.Array2DTypeTypeNotSupport:
                throw new ArgumentException("Output or input type is not supported.");
            }
        }
Exemplo n.º 7
0
 public static extern ErrorType draw_line(Array2DType pixelType, IntPtr image, IntPtr p1, IntPtr p2, ref LabPixel color);
Exemplo n.º 8
0
 public static extern ErrorType fill_rect_matrix(MatrixElementType elementType, IntPtr matrix, IntPtr rect, ref LabPixel color);
Exemplo n.º 9
0
 public static extern ErrorType fill_rect(Array2DType pixelType, IntPtr image, IntPtr rect, ref LabPixel color);
Exemplo n.º 10
0
 public static extern ErrorType draw_line_canvas_infinity(IntPtr canvas, IntPtr p1, IntPtr p2, Array2DType pixelType, ref LabPixel color);
Exemplo n.º 11
0
 public static extern void assign_pixel_rgbalpha_lab(ref RgbAlphaPixel dest, ref LabPixel src);
Exemplo n.º 12
0
 public static extern ErrorType image_window_add_overlay(IntPtr window, IntPtr rect, Array2DType type, ref LabPixel color);
Exemplo n.º 13
0
 public OverlayDot(Vector <double> point, LabPixel pixel) :
     this(NativeMethods.perspective_window_overlay_dot_new2(point.NativePtr, NativeMethods.Array2DType.LabPixel, ref pixel))
 {
 }
Exemplo n.º 14
0
 public static extern ErrorType array_pixel_getitem_lab_pixel(Array2DType type, IntPtr array, uint index, out LabPixel item);
Exemplo n.º 15
0
 public static extern ErrorType array_pixel_pushback_lab_pixel(Array2DType type, IntPtr array, LabPixel item);
Exemplo n.º 16
0
 public static extern ErrorType draw_line_matrix(MatrixElementType elementType, IntPtr matrix, IntPtr p1, IntPtr p2, ref LabPixel color);
Exemplo n.º 17
0
 public static extern ErrorType perspective_window_add_overlay3(IntPtr window, IntPtr vector, Array2DType type, ref LabPixel color);
Exemplo n.º 18
0
 public static extern ErrorType assign_all_pixels(Array2DType out_type, IntPtr out_img, Array2DType in_type, ref LabPixel color);
Exemplo n.º 19
0
 public static extern void array2d_get_row_column_lab_pixel(IntPtr row, int column, out LabPixel value);
Exemplo n.º 20
0
 public static extern ErrorType draw_rectangle(Array2DType pixelType, IntPtr image, IntPtr rect, ref LabPixel color, uint thickness);
Exemplo n.º 21
0
 public static extern IntPtr perspective_window_overlay_dot_new2(IntPtr v, Array2DType type, ref LabPixel color);
Exemplo n.º 22
0
 public static extern ErrorType draw_rectangle_matrix(MatrixElementType elementType, IntPtr matrix, IntPtr rect, ref LabPixel color, uint thickness);
Exemplo n.º 23
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);
        }
Exemplo n.º 24
0
 public static extern ErrorType draw_rectangle_canvas_infinity(IntPtr canvas, IntPtr rect, Array2DType pixelType, ref LabPixel color);