/// <summary> /// /// </summary> /// <typeparam name="T"></typeparam> /// <param name="elem"></param> /// <param name="writer"></param> #else /// <summary> /// /// </summary> /// <typeparam name="T"></typeparam> /// <param name="elem"></param> /// <param name="writer"></param> #endif public static void WRITE_SEQ_ELEM <T>(T elem, CvSeqWriter writer) where T : struct { int size = Marshal.SizeOf(typeof(T)); if (writer.Seq.ElemSize != size) { throw new OpenCvSharpException(); } if (writer.Ptr.ToInt64() >= writer.BlockMax.ToInt64()) { NativeMethods.cvCreateSeqBlock(writer.CvPtr); } if (writer.Ptr.ToInt64() > writer.BlockMax.ToInt64() - size) { throw new OpenCvSharpException(); } using (var elemPtr = new StructurePointer <T>(elem)) { Util.CopyMemory(writer.Ptr, elemPtr, size); } writer.Ptr = new IntPtr(writer.Ptr.ToInt64() + size); }
/// <summary> /// /// </summary> /// <param name="elemPtr"></param> /// <param name="writer"></param> #else /// <summary> /// /// </summary> /// <param name="elemPtr"></param> /// <param name="writer"></param> #endif public static void WRITE_SEQ_ELEM_VAR(IntPtr elemPtr, CvSeqWriter writer) { int elemSize = writer.Seq.ElemSize; if (writer.Ptr.ToInt64() >= writer.BlockMax.ToInt64()) { NativeMethods.cvCreateSeqBlock(writer.CvPtr); } Util.CopyMemory(writer.Ptr, elemPtr, elemSize); writer.Ptr = new IntPtr(writer.Ptr.ToInt64() + elemSize); }
/// <summary> /// /// </summary> /// <typeparam name="T"></typeparam> /// <param name="elem"></param> /// <param name="writer"></param> #else /// <summary> /// /// </summary> /// <typeparam name="T"></typeparam> /// <param name="elem"></param> /// <param name="writer"></param> #endif public static void WRITE_SEQ_ELEM <T>(T elem, CvSeqWriter <T> writer) where T : struct { WRITE_SEQ_ELEM(elem, (CvSeqWriter)writer); }
/// <summary> /// ジェネリックなし版のWriterから初期化 /// </summary> /// <param name="writer"></param> #else /// <summary> /// Initializes from non generic writer /// </summary> /// <param name="writer"></param> #endif public CvSeqWriter(CvSeqWriter writer) : base(writer.CvPtr) { }