public static void AssignAllPpixels(Array2D <BgrPixel> dest, BgrPixel 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.BgrPixel, ref pixel); switch (ret) { case NativeMethods.ErrorType.Array2DTypeTypeNotSupport: throw new ArgumentException("Output or input type is not supported."); } }
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); }
public static extern void array2d_get_row_column_bgr_pixel(IntPtr row, int column, out BgrPixel value);
public static extern ErrorType array_pixel_pushback_bgr_pixel(Array2DType type, IntPtr array, BgrPixel item);
public static extern ErrorType array_pixel_getitem_bgr_pixel(Array2DType type, IntPtr array, uint index, out BgrPixel item);
public static extern ErrorType assign_all_pixels(Array2DType out_type, IntPtr out_img, Array2DType in_type, ref BgrPixel color);
public static extern IntPtr image_window_overlay_line_new_bgr(IntPtr p1, IntPtr p2, BgrPixel pixel);
public OverlayLine(Point p1, Point p2, BgrPixel pixel) { using (var native1 = p1.ToNative()) using (var native2 = p2.ToNative()) this.NativePtr = NativeMethods.image_window_overlay_line_new_bgr(native1.NativePtr, native2.NativePtr, pixel); }