public void SetImage(MatrixOp matrix) { this.ThrowIfDisposed(); if (matrix == null) { throw new ArgumentNullException(nameof(matrix)); } matrix.ThrowIfDisposed(); NativeMethods.ErrorType ret; switch (matrix.ElementType) { case NativeMethods.ElementType.OpHeatmap: case NativeMethods.ElementType.OpJet: case NativeMethods.ElementType.OpArray2DToMat: case NativeMethods.ElementType.OpTrans: case NativeMethods.ElementType.OpStdVectToMat: ret = NativeMethods.image_window_set_image_matrix_op_array2d(this.NativePtr, matrix.ElementType, matrix.Array2DType, matrix.NativePtr); break; case NativeMethods.ElementType.OpJoinRows: ret = NativeMethods.image_window_set_image_matrix_op_matrix(this.NativePtr, matrix.ElementType, matrix.MatrixElementType, matrix.NativePtr); break; default: throw new ArgumentOutOfRangeException(); } switch (ret) { case NativeMethods.ErrorType.Array2DTypeTypeNotSupport: throw new ArgumentException($"{matrix.Array2DType} is not supported."); case NativeMethods.ErrorType.MatrixElementTypeNotSupport: throw new ArgumentException($"{matrix.MatrixElementType} is not supported."); case NativeMethods.ErrorType.MatrixOpTypeNotSupport: throw new ArgumentException($"{matrix.ElementType} is not supported."); } }
public static Point MaxPoint(MatrixOp matrix) { if (matrix == null) { throw new ArgumentNullException(nameof(matrix)); } matrix.ThrowIfDisposed(); var type = matrix.Array2DType; var ret = NativeMethods.matrix_max_point(type, matrix.NativePtr, out var point); switch (ret) { case NativeMethods.ErrorType.MatrixElementTypeNotSupport: throw new ArgumentException($"{type} is not supported."); } return(new Point(point)); }
public ImageWindow(MatrixOp matrix, string title) { if (matrix == null) { throw new ArgumentNullException(nameof(matrix)); } if (title == null) { throw new ArgumentNullException(nameof(title)); } matrix.ThrowIfDisposed(nameof(matrix)); var str = Dlib.Encoding.GetBytes(title); IntPtr ret; NativeMethods.ErrorType err; var tr = matrix.TemplateRows; var tc = matrix.TemplateColumns; var et = matrix.ElementType; var ptr = matrix.NativePtr; if (tr == -1 && matrix.TemplateColumns == -1) { err = NativeMethods.image_window_new_matrix_op2(et, matrix.Array2DType, ptr, str, str.Length, out ret); } else { err = NativeMethods.image_window_new_matrix_op4(et, matrix.MatrixElementType, ptr, tr, tc, str, str.Length, out ret); } switch (err) { case NativeMethods.ErrorType.MatrixOpTypeNotSupport: throw new ArgumentException($"{matrix.ElementType} is not supported."); } this.NativePtr = ret; }
public ImageWindow(MatrixOp matrix, string title) { if (matrix == null) { throw new ArgumentNullException(nameof(matrix)); } if (title == null) { throw new ArgumentNullException(nameof(title)); } matrix.ThrowIfDisposed(nameof(matrix)); var str = Encoding.UTF8.GetBytes(title); if (matrix.TemplateRows == -1 && matrix.TemplateColumns == -1) { this.NativePtr = Native.image_window_new_matrix_op2(matrix.ElementType, matrix.Array2DType, matrix.NativePtr, str); } else { this.NativePtr = Native.image_window_new_matrix_op4(matrix.ElementType, matrix.MatrixElementType, matrix.NativePtr, matrix.TemplateRows, matrix.TemplateColumns, str); } }