Пример #1
0
        /// <summary>
        /// Releases all unmanaged resources.
        /// </summary>
        protected override void DisposeUnmanaged()
        {
            base.DisposeUnmanaged();

            if (this.NativePtr == IntPtr.Zero)
            {
                return;
            }

            switch (this._ElementType)
            {
            case NativeMethods.ElementType.OpHeatmap:
                NativeMethods.matrix_op_op_heatmap_delete(this._Array2DType, this.NativePtr);
                break;

            case NativeMethods.ElementType.OpJet:
                NativeMethods.matrix_op_op_jet_delete(this._Array2DType, this.NativePtr);
                break;

            case NativeMethods.ElementType.OpArray2DToMat:
                NativeMethods.matrix_op_op_array2d_to_mat_delete(this._Array2DType, this.NativePtr);
                break;

            case NativeMethods.ElementType.OpTrans:
                NativeMethods.matrix_op_op_trans_delete(this._MatrixElementType, this.NativePtr, this.TemplateRows, this.TemplateColumns);
                break;

            case NativeMethods.ElementType.OpStdVectToMat:
                NativeMethods.matrix_op_op_std_vect_to_mat_delete(this._MatrixElementType, this.NativePtr, this.TemplateRows, this.TemplateColumns);
                break;

            case NativeMethods.ElementType.OpStdVectToMatValue:
                DlibObject vector = null;
                switch (this._Array2DType)
                {
                case NativeMethods.Array2DType.UInt8:
                    vector = new StdVector <byte>(this._Ref);
                    break;

                case NativeMethods.Array2DType.UInt16:
                    vector = new StdVector <ushort>(this._Ref);
                    break;

                case NativeMethods.Array2DType.UInt32:
                    vector = new StdVector <uint>(this._Ref);
                    break;

                case NativeMethods.Array2DType.Int8:
                    vector = new StdVector <sbyte>(this._Ref);
                    break;

                case NativeMethods.Array2DType.Int16:
                    vector = new StdVector <short>(this._Ref);
                    break;

                case NativeMethods.Array2DType.Int32:
                    vector = new StdVector <int>(this._Ref);
                    break;

                case NativeMethods.Array2DType.Float:
                    vector = new StdVector <float>(this._Ref);
                    break;

                case NativeMethods.Array2DType.Double:
                    vector = new StdVector <double>(this._Ref);
                    break;

                case NativeMethods.Array2DType.RgbPixel:
                    vector = new StdVector <RgbPixel>(this._Ref);
                    break;

                case NativeMethods.Array2DType.RgbAlphaPixel:
                    vector = new StdVector <RgbAlphaPixel>(this._Ref);
                    break;

                case NativeMethods.Array2DType.HsiPixel:
                    vector = new StdVector <HsiPixel>(this._Ref);
                    break;
                }
                vector?.Dispose();
                NativeMethods.matrix_op_op_std_vect_to_mat_value_delete(this._Array2DType, this.NativePtr);
                break;

            case NativeMethods.ElementType.OpJoinRows:
                NativeMethods.matrix_op_op_join_rows_delete(this._MatrixElementType, this.NativePtr, this.TemplateRows, this.TemplateColumns);
                break;
            }
        }