Exemplo n.º 1
0
        // tiffio.c (2703, 1)
        // pixWriteMemTiffCustom(pdata, psize, pix, comptype, natags, savals, satypes, nasizes) as int
        // pixWriteMemTiffCustom(l_uint8 **, size_t *, PIX *, l_int32, NUMA *, SARRAY *, SARRAY *, NUMA *) as l_ok
        ///  <summary>
        /// pixWriteMemTiffCustom()
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/pixWriteMemTiffCustom/*"/>
        ///  <param name="pdata">[out] - data of tiff compressed image</param>
        ///  <param name="psize">[out] - size of returned data</param>
        ///  <param name="pix">[in] - </param>
        ///  <param name="comptype">[in] - IFF_TIFF, IFF_TIFF_RLE, IFF_TIFF_PACKBITS, IFF_TIFF_G3, IFF_TIFF_G4, IFF_TIFF_LZW, IFF_TIFF_ZIP</param>
        ///  <param name="natags">[in][optional] - NUMA of custom tiff tags</param>
        ///  <param name="savals">[in][optional] - SARRAY of values</param>
        ///  <param name="satypes">[in][optional] - SARRAY of types</param>
        ///  <param name="nasizes">[in][optional] - NUMA of sizes</param>
        ///   <returns>0 if OK, 1 on error Usage: 1) See pixWriteTiffCustom(.  This version writes to memory instead of to a file. 2) Use TIFFClose() TIFFCleanup( doesn't free internal memstream.</returns>
        public static int pixWriteMemTiffCustom(
            out Byte[] pdata,
            out uint psize,
            Pix pix,
            int comptype,
            Numa natags    = null,
            Sarray savals  = null,
            Sarray satypes = null,
            Numa nasizes   = null)
        {
            if (pix == null)
            {
                throw new ArgumentNullException("pix cannot be Nothing");
            }

            IntPtr pdataPtr  = IntPtr.Zero;
            IntPtr natagsPtr = IntPtr.Zero;         if (natags != null)
            {
                natagsPtr = natags.Pointer;
            }
            IntPtr savalsPtr = IntPtr.Zero;         if (savals != null)
            {
                savalsPtr = savals.Pointer;
            }
            IntPtr satypesPtr = IntPtr.Zero;        if (satypes != null)
            {
                satypesPtr = satypes.Pointer;
            }
            IntPtr nasizesPtr = IntPtr.Zero;        if (nasizes != null)
            {
                nasizesPtr = nasizes.Pointer;
            }
            int _Result = Natives.pixWriteMemTiffCustom(out pdataPtr, out psize, pix.Pointer, comptype, natagsPtr, savalsPtr, satypesPtr, nasizesPtr);

            Byte[] pdataGen = new Byte[psize];

            if (pdataPtr != IntPtr.Zero)
            {
                Marshal.Copy(pdataPtr, pdataGen, 0, pdataGen.Length);
            }

            pdata = pdataGen;
            return(_Result);
        }
Exemplo n.º 2
0
        // sarray1.c (446, 1)
        // sarrayAddString(sa, string, copyflag) as int
        // sarrayAddString(SARRAY *, const char *, l_int32) as l_ok
        ///  <summary>
        /// (1) See usage comments at the top of this file.  L_INSERT is
        /// equivalent to L_NOCOPY.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/sarrayAddString/*"/>
        ///  <param name="sa">[in] - string array</param>
        ///  <param name="copyflag">[in] - L_INSERT, L_NOCOPY or L_COPY</param>
        ///   <returns>0 if OK, 1 on error</returns>
        public static int sarrayAddString(
            Sarray sa,
            String _string_,
            int copyflag)
        {
            if (sa == null)
            {
                throw new ArgumentNullException("sa cannot be Nothing");
            }

            if (_string_ == null)
            {
                throw new ArgumentNullException("_string_ cannot be Nothing");
            }

            int _Result = Natives.sarrayAddString(sa.Pointer, _string_, copyflag);

            return(_Result);
        }
Exemplo n.º 3
0
        // sarray1.c (1191, 1)
        // sarraySelectByRange(sain, first, last) as Sarray
        // sarraySelectByRange(SARRAY *, l_int32, l_int32) as SARRAY *
        ///  <summary>
        /// (1) This makes %saout consisting of copies of all strings in %sain
        /// in the index set [first ... last].  Use %last == 0 to get all
        /// strings from %first to the last string in the sarray.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/sarraySelectByRange/*"/>
        ///  <param name="sain">[in] - input sarray</param>
        ///  <param name="first">[in] - index of first string to be selected</param>
        ///  <param name="last">[in] - index of last string to be selected use 0 to go to the end of the sarray</param>
        ///   <returns>saout output sarray, or NULL on error</returns>
        public static Sarray sarraySelectByRange(
            Sarray sain,
            int first,
            int last)
        {
            if (sain == null)
            {
                throw new ArgumentNullException("sain cannot be Nothing");
            }

            IntPtr _Result = Natives.sarraySelectByRange(sain.Pointer, first, last);

            if (_Result == IntPtr.Zero)
            {
                return(null);
            }

            return(new Sarray(_Result));
        }
Exemplo n.º 4
0
        // sarray1.c (355, 1)
        // sarrayDestroy(psa) as Object
        // sarrayDestroy(SARRAY **) as void
        ///  <summary>
        /// (1) Decrements the ref count and, if 0, destroys the sarray.<para/>
        ///
        /// (2) Always nulls the input ptr.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/sarrayDestroy/*"/>
        ///  <param name="psa">[in,out] - to be nulled</param>
        public static void sarrayDestroy(
            ref Sarray psa)
        {
            IntPtr psaPtr = IntPtr.Zero;    if (psa != null)

            {
                psaPtr = psa.Pointer;
            }

            Natives.sarrayDestroy(ref psaPtr);
            if (psaPtr == IntPtr.Zero)
            {
                psa = null;
            }
            else
            {
                psa = new Sarray(psaPtr);
            };
        }
Exemplo n.º 5
0
        // sarray1.c (1777, 1)
        // convertSortedToNumberedPathnames(sa, numpre, numpost, maxnum) as Sarray
        // convertSortedToNumberedPathnames(SARRAY *, l_int32, l_int32, l_int32) as SARRAY *
        ///  <summary>
        /// (1) Typically, numpre = numpost = 0 e.g., when the filename
        /// just has a number followed by an optional extension.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/convertSortedToNumberedPathnames/*"/>
        ///  <param name="sa">[in] - sorted pathnames including zero-padded integers</param>
        ///  <param name="numpre">[in] - number of characters in name before number</param>
        ///  <param name="numpost">[in] - number of characters in name after the number, up to a dot before an extension</param>
        ///  <param name="maxnum">[in] - only consider page numbers up to this value</param>
        ///   <returns>sarray of numbered pathnames, or NULL on error</returns>
        public static Sarray convertSortedToNumberedPathnames(
            Sarray sa,
            int numpre,
            int numpost,
            int maxnum)
        {
            if (sa == null)
            {
                throw new ArgumentNullException("sa cannot be Nothing");
            }

            IntPtr _Result = Natives.convertSortedToNumberedPathnames(sa.Pointer, numpre, numpost, maxnum);

            if (_Result == IntPtr.Zero)
            {
                return(null);
            }

            return(new Sarray(_Result));
        }
Exemplo n.º 6
0
        // sarray1.c (920, 1)
        // sarrayAppendRange(sa1, sa2, start, end) as int
        // sarrayAppendRange(SARRAY *, SARRAY *, l_int32, l_int32) as l_ok
        ///  <summary>
        /// (1) Copies of the strings in sarray2 are added to sarray1.<para/>
        ///
        /// (2) The [start ... end] range is truncated if necessary.<para/>
        ///
        /// (3) Use end == -1 to append to the end of sa2.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/sarrayAppendRange/*"/>
        ///  <param name="sa1">[in] - to be added to</param>
        ///  <param name="sa2">[in] - append specified range of strings in sa2 to sa1</param>
        ///  <param name="start">[in] - index of first string of sa2 to append</param>
        ///   <returns>0 if OK, 1 on error</returns>
        public static int sarrayAppendRange(
            Sarray sa1,
            Sarray sa2,
            int start,
            int _end_)
        {
            if (sa1 == null)
            {
                throw new ArgumentNullException("sa1 cannot be Nothing");
            }

            if (sa2 == null)
            {
                throw new ArgumentNullException("sa2 cannot be Nothing");
            }

            int _Result = Natives.sarrayAppendRange(sa1.Pointer, sa2.Pointer, start, _end_);

            return(_Result);
        }
Exemplo n.º 7
0
        // sarray1.c (557, 1)
        // sarrayReplaceString(sa, index, newstr, copyflag) as int
        // sarrayReplaceString(SARRAY *, l_int32, char *, l_int32) as l_ok
        ///  <summary>
        /// (1) This destroys an existing string and replaces it with
        /// the new string or a copy of it.<para/>
        ///
        /// (2) By design, an sarray is always compacted, so there are
        /// never any holes (null ptrs) in the ptr array up to the
        /// current count.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/sarrayReplaceString/*"/>
        ///  <param name="sa">[in] - string array</param>
        ///  <param name="index">[in] - of string within sarray to be replaced</param>
        ///  <param name="newstr">[in] - string to replace existing one</param>
        ///  <param name="copyflag">[in] - L_INSERT, L_COPY</param>
        ///   <returns>0 if OK, 1 on error</returns>
        public static int sarrayReplaceString(
            Sarray sa,
            int index,
            String newstr,
            int copyflag)
        {
            if (sa == null)
            {
                throw new ArgumentNullException("sa cannot be Nothing");
            }

            if (newstr == null)
            {
                throw new ArgumentNullException("newstr cannot be Nothing");
            }

            int _Result = Natives.sarrayReplaceString(sa.Pointer, index, newstr, copyflag);

            return(_Result);
        }
Exemplo n.º 8
0
        // jbclass.c (444, 1)
        // jbAddPages(classer, safiles) as int
        // jbAddPages(JBCLASSER *, SARRAY *) as l_ok
        ///  <summary>
        /// (1) jbclasser makes a copy of the array of file names.<para/>
        ///
        /// (2) The caller is still responsible for destroying the input array.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/jbAddPages/*"/>
        ///  <param name="safiles">[in] - of page image file names</param>
        ///   <returns>0 if OK 1 on error</returns>
        public static int jbAddPages(
            JbClasser classer,
            Sarray safiles)
        {
            if (classer == null)
            {
                throw new ArgumentNullException("classer cannot be Nothing");
            }

            if (safiles == null)
            {
                throw new ArgumentNullException("safiles cannot be Nothing");
            }

            IntPtr classerPtr = IntPtr.Zero; if (classer != null)
            {
                classerPtr = classer.Pointer;
            }
            int _Result = Natives.jbAddPages(classer.Pointer, safiles.Pointer);

            return(_Result);
        }
Exemplo n.º 9
0
        // psio1.c (201, 1)
        // sarrayConvertFilesToPS(sa, res, fileout) as int
        // sarrayConvertFilesToPS(SARRAY *, l_int32, const char *) as l_ok
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/sarrayConvertFilesToPS/*"/>
        ///   <returns></returns>
        public static int sarrayConvertFilesToPS(
            Sarray sa,
            int res,
            String fileout)
        {
            if (sa == null)
            {
                throw new ArgumentNullException("sa cannot be Nothing");
            }

            if (fileout == null)
            {
                throw new ArgumentNullException("fileout cannot be Nothing");
            }

            IntPtr saPtr = IntPtr.Zero; if (sa != null)
            {
                saPtr = sa.Pointer;
            }
            int _Result = Natives.sarrayConvertFilesToPS(sa.Pointer, res, fileout);

            return(_Result);
        }
Exemplo n.º 10
0
        // recogtrain.c (1650, 1)
        // recogIsPaddingNeeded(recog, psa) as int
        // recogIsPaddingNeeded(L_RECOG *, SARRAY **) as l_int32
        ///  <summary>
        /// (1) This returns a string array in [and]sa containing character values
        /// for which extra templates are needed this sarray is
        /// used by recogGetPadTemplates().  It returns NULL
        /// if no padding templates are needed.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/recogIsPaddingNeeded/*"/>
        ///  <param name="recog">[in] - trained</param>
        ///  <param name="psa">[out] - addr of returned string containing text value</param>
        ///   <returns>1 on error 0 if OK, whether or not additional padding templates are required.</returns>
        public static int recogIsPaddingNeeded(
            L_Recog recog,
            out Sarray psa)
        {
            if (recog == null)
            {
                throw new ArgumentNullException("recog cannot be Nothing");
            }

            IntPtr psaPtr  = IntPtr.Zero;
            int    _Result = Natives.recogIsPaddingNeeded(recog.Pointer, out psaPtr);

            if (psaPtr == IntPtr.Zero)
            {
                psa = null;
            }
            else
            {
                psa = new Sarray(psaPtr);
            };

            return(_Result);
        }
Exemplo n.º 11
0
        // recogtrain.c (1768, 1)
        // recogAddDigitPadTemplates(recog, sa) as Pixa
        // recogAddDigitPadTemplates(L_RECOG *, SARRAY *) as PIXA *
        ///  <summary>
        /// (1) Call recogIsPaddingNeeded() first, which returns %sa of
        /// template text strings for classes where more templates
        /// are needed.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/recogAddDigitPadTemplates/*"/>
        ///  <param name="recog">[in] - trained</param>
        ///  <param name="sa">[in] - set of text strings that need to be padded</param>
        ///   <returns>pixa   of all templates from %recog and the additional pad templates from a boot recognizer or NULL on error</returns>
        public static Pixa recogAddDigitPadTemplates(
            L_Recog recog,
            Sarray sa)
        {
            if (recog == null)
            {
                throw new ArgumentNullException("recog cannot be Nothing");
            }

            if (sa == null)
            {
                throw new ArgumentNullException("sa cannot be Nothing");
            }

            IntPtr _Result = Natives.recogAddDigitPadTemplates(recog.Pointer, sa.Pointer);

            if (_Result == IntPtr.Zero)
            {
                return(null);
            }

            return(new Pixa(_Result));
        }
Exemplo n.º 12
0
        // sarray2.c (488, 1)
        // sarrayIntersectionByHash(sa1, sa2) as Sarray
        // sarrayIntersectionByHash(SARRAY *, SARRAY *) as SARRAY *
        ///  <summary>
        /// (1) This is faster than sarrayIntersectionByAset(), because the
        /// bucket lookup is O(n).
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/sarrayIntersectionByHash/*"/>
        ///  <param name="sa1">[in] - </param>
        ///  <param name="sa2">[in] - </param>
        ///   <returns>sad intersection of the strings, or NULL on error</returns>
        public static Sarray sarrayIntersectionByHash(
            Sarray sa1,
            Sarray sa2)
        {
            if (sa1 == null)
            {
                throw new ArgumentNullException("sa1 cannot be Nothing");
            }

            if (sa2 == null)
            {
                throw new ArgumentNullException("sa2 cannot be Nothing");
            }

            IntPtr _Result = Natives.sarrayIntersectionByHash(sa1.Pointer, sa2.Pointer);

            if (_Result == IntPtr.Zero)
            {
                return(null);
            }

            return(new Sarray(_Result));
        }
Exemplo n.º 13
0
        // sarray1.c (1260, 1)
        // sarrayParseRange(sa, start, pactualstart, pend, pnewstart, substr, loc) as int
        // sarrayParseRange(SARRAY *, l_int32, l_int32 *, l_int32 *, l_int32 *, const char *, l_int32) as l_int32
        ///  <summary>
        /// (1) This finds the range of the next set of strings in SA,
        /// beginning the search at 'start', that does NOT have
        /// the substring 'substr' either at the indicated location
        /// in the string or anywhere in the string.  The input
        /// variable 'loc' is the specified offset within the string
        /// use -1 to indicate 'anywhere in the string'.<para/>
        ///
        /// (2) Always check the return value to verify that a valid range
        /// was found.<para/>
        ///
        /// (3) If a valid range is not found, the values of actstart,
        /// end and newstart are all set to the size of sa.<para/>
        ///
        /// (4) If this is the last valid range, newstart returns the value n.
        /// In use, this should be tested before calling the function.<para/>
        ///
        /// (5) Usage example.  To find all the valid ranges in a file
        /// where the invalid lines begin with two dashes, copy each
        /// line in the file to a string in an sarray, and do:
        /// start = 0
        /// while (!sarrayParseRange(sa, start, [and]actstart, [and]end, [and]start,
        /// "--", 0))
        /// fprintf(stderr, "start = %d, end = %d\n", actstart, end)
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/sarrayParseRange/*"/>
        ///  <param name="sa">[in] - input sarray</param>
        ///  <param name="start">[in] - index to start range search</param>
        ///  <param name="pactualstart">[out] - index of actual start may be  is greater  'start'</param>
        ///  <param name="pend">[out] - index of end</param>
        ///  <param name="pnewstart">[out] - index of start of next range</param>
        ///  <param name="substr">[in] - substring for matching at beginning of string</param>
        ///  <param name="loc">[in] - byte offset within the string for the pattern use -1 if the location does not matter</param>
        ///   <returns>0 if valid range found 1 otherwise</returns>
        public static int sarrayParseRange(
            Sarray sa,
            int start,
            out int pactualstart,
            out int pend,
            out int pnewstart,
            String substr,
            int loc)
        {
            if (sa == null)
            {
                throw new ArgumentNullException("sa cannot be Nothing");
            }

            if (substr == null)
            {
                throw new ArgumentNullException("substr cannot be Nothing");
            }

            int _Result = Natives.sarrayParseRange(sa.Pointer, start, out pactualstart, out pend, out pnewstart, substr, loc);

            return(_Result);
        }
Exemplo n.º 14
0
        // sarray2.c (145, 1)
        // sarraySortByIndex(sain, naindex) as Sarray
        // sarraySortByIndex(SARRAY *, NUMA *) as SARRAY *
        ///  <summary>
        /// sarraySortByIndex()
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/sarraySortByIndex/*"/>
        ///  <param name="sain">[in] - </param>
        ///  <param name="naindex">[in] - na that maps from the new sarray to the input sarray</param>
        ///   <returns>saout sorted, or NULL on error</returns>
        public static Sarray sarraySortByIndex(
            Sarray sain,
            Numa naindex)
        {
            if (sain == null)
            {
                throw new ArgumentNullException("sain cannot be Nothing");
            }

            if (naindex == null)
            {
                throw new ArgumentNullException("naindex cannot be Nothing");
            }

            IntPtr _Result = Natives.sarraySortByIndex(sain.Pointer, naindex.Pointer);

            if (_Result == IntPtr.Zero)
            {
                return(null);
            }

            return(new Sarray(_Result));
        }
Exemplo n.º 15
0
        // sarray1.c (1553, 1)
        // sarrayWriteMem(pdata, psize, sa) as int
        // sarrayWriteMem(l_uint8 **, size_t *, SARRAY *) as l_ok
        ///  <summary>
        /// (1) Serializes a sarray in memory and puts the result in a buffer.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/sarrayWriteMem/*"/>
        ///  <param name="pdata">[out] - data of serialized sarray ascii</param>
        ///  <param name="psize">[out] - size of returned data</param>
        ///  <param name="sa">[in] - </param>
        ///   <returns>0 if OK, 1 on error</returns>
        public static int sarrayWriteMem(
            out Byte[] pdata,
            out uint psize,
            Sarray sa)
        {
            if (sa == null)
            {
                throw new ArgumentNullException("sa cannot be Nothing");
            }

            IntPtr pdataPtr = IntPtr.Zero;
            int    _Result  = Natives.sarrayWriteMem(out pdataPtr, out psize, sa.Pointer);

            Byte[] pdataGen = new Byte[psize];

            if (pdataPtr != IntPtr.Zero)
            {
                Marshal.Copy(pdataPtr, pdataGen, 0, pdataGen.Length);
            }

            pdata = pdataGen;
            return(_Result);
        }
Exemplo n.º 16
0
        // sarray1.c (972, 1)
        // sarrayPadToSameSize(sa1, sa2, padstring) as int
        // sarrayPadToSameSize(SARRAY *, SARRAY *, const char *) as l_ok
        ///  <summary>
        /// (1) If two sarrays have different size, this adds enough
        /// instances of %padstring to the smaller so that they are
        /// the same size.  It is useful when two or more sarrays
        /// are being sequenced in parallel, and it is necessary to
        /// find a valid string at each index.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/sarrayPadToSameSize/*"/>
        ///  <param name="sa1">[in] - </param>
        ///  <param name="sa2">[in] - </param>
        ///  <param name="padstring">[in] - </param>
        ///   <returns>0 if OK, 1 on error</returns>
        public static int sarrayPadToSameSize(
            Sarray sa1,
            Sarray sa2,
            String padstring)
        {
            if (sa1 == null)
            {
                throw new ArgumentNullException("sa1 cannot be Nothing");
            }

            if (sa2 == null)
            {
                throw new ArgumentNullException("sa2 cannot be Nothing");
            }

            if (padstring == null)
            {
                throw new ArgumentNullException("padstring cannot be Nothing");
            }

            int _Result = Natives.sarrayPadToSameSize(sa1.Pointer, sa2.Pointer, padstring);

            return(_Result);
        }
Exemplo n.º 17
0
        // sarray2.c (95, 1)
        // sarraySort(saout, sain, sortorder) as Sarray
        // sarraySort(SARRAY *, SARRAY *, l_int32) as SARRAY *
        ///  <summary>
        /// (1) Set saout = sain for in-place otherwise, set naout = NULL.<para/>
        ///
        /// (2) Shell sort, modified from K[and]R, 2nd edition, p.62.
        /// Slow but simple O(n logn) sort.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/sarraySort/*"/>
        ///  <param name="saout">[in] - output sarray can be NULL or equal to sain</param>
        ///  <param name="sain">[in] - input sarray</param>
        ///  <param name="sortorder">[in] - L_SORT_INCREASING or L_SORT_DECREASING</param>
        ///   <returns>saout output sarray, sorted by ascii value, or NULL on error</returns>
        public static Sarray sarraySort(
            Sarray saout,
            Sarray sain,
            int sortorder)
        {
            if (saout == null)
            {
                throw new ArgumentNullException("saout cannot be Nothing");
            }

            if (sain == null)
            {
                throw new ArgumentNullException("sain cannot be Nothing");
            }

            IntPtr _Result = Natives.sarraySort(saout.Pointer, sain.Pointer, sortorder);

            if (_Result == IntPtr.Zero)
            {
                return(null);
            }

            return(new Sarray(_Result));
        }
Exemplo n.º 18
0
        // sarray1.c (1601, 1)
        // sarrayAppend(filename, sa) as int
        // sarrayAppend(const char *, SARRAY *) as l_ok
        ///  <summary>
        /// sarrayAppend()
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/sarrayAppend/*"/>
        ///  <param name="filename">[in] - </param>
        ///  <param name="sa">[in] - </param>
        ///   <returns>0 if OK 1 on error</returns>
        public static int sarrayAppend(
            String filename,
            Sarray sa)
        {
            if (filename == null)
            {
                throw new ArgumentNullException("filename cannot be Nothing");
            }

            if (sa == null)
            {
                throw new ArgumentNullException("sa cannot be Nothing");
            }

            if (File.Exists(filename) == false)
            {
                throw new ArgumentException("File is missing");
            }
            ;

            int _Result = Natives.sarrayAppend(filename, sa.Pointer);

            return(_Result);
        }
Exemplo n.º 19
0
        // sarray1.c (646, 1)
        // sarrayGetArray(sa, pnalloc, pn) as String[]
        // sarrayGetArray(SARRAY *, l_int32 *, l_int32 *) as char **
        ///  <summary>
        /// (1) Caution: the returned array is not a copy, so caller
        /// must not destroy it!
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/sarrayGetArray/*"/>
        ///  <param name="sa">[in] - string array</param>
        ///  <param name="pnalloc">[out][optional] - number allocated string ptrs</param>
        ///  <param name="pn">[out][optional] - number allocated strings</param>
        ///   <returns>ptr to string array, or NULL on error</returns>
        public static String[] sarrayGetArray(
            Sarray sa,
            out int pnalloc,
            out int pn)
        {
            if (sa == null)
            {
                throw new ArgumentNullException("sa cannot be Nothing");
            }

            IntPtr _Result = Natives.sarrayGetArray(sa.Pointer, out pnalloc, out pn);

            IntPtr[] PTRArr = new IntPtr[pn];
            Marshal.Copy(_Result, PTRArr, 0, PTRArr.Length);
            List <String> BLST = new List <String>();

            foreach (IntPtr eintrag in PTRArr)
            {
                BLST.Add(Marshal.PtrToStringAnsi(eintrag));
            }

            String[] B = BLST.ToArray();
            return(B);
        }
Exemplo n.º 20
0
        // recogident.c (1281, 1)
        // rchaExtract(rcha, pnaindex, pnascore, psatext, pnasample, pnaxloc, pnayloc, pnawidth) as int
        // rchaExtract(L_RCHA *, NUMA **, NUMA **, SARRAY **, NUMA **, NUMA **, NUMA **, NUMA **) as l_ok
        ///  <summary>
        /// (1) This returns clones of the number and string arrays.  They must
        /// be destroyed by the caller.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/rchaExtract/*"/>
        ///  <param name="rcha">[in] - </param>
        ///  <param name="pnaindex">[out][optional] - indices of best templates</param>
        ///  <param name="pnascore">[out][optional] - correl scores of best templates</param>
        ///  <param name="psatext">[out][optional] - character strings of best templates</param>
        ///  <param name="pnasample">[out][optional] - indices of best samples</param>
        ///  <param name="pnaxloc">[out][optional] - x-locations of templates</param>
        ///  <param name="pnayloc">[out][optional] - y-locations of templates</param>
        ///  <param name="pnawidth">[out][optional] - widths of best templates</param>
        ///   <returns>0 if OK, 1 on error</returns>
        public static int rchaExtract(
            L_Rcha rcha,
            out Numa pnaindex,
            out Numa pnascore,
            out Sarray psatext,
            out Numa pnasample,
            out Numa pnaxloc,
            out Numa pnayloc,
            out Numa pnawidth)
        {
            if (rcha == null)
            {
                throw new ArgumentNullException("rcha cannot be Nothing");
            }

            IntPtr pnaindexPtr  = IntPtr.Zero;
            IntPtr pnascorePtr  = IntPtr.Zero;
            IntPtr psatextPtr   = IntPtr.Zero;
            IntPtr pnasamplePtr = IntPtr.Zero;
            IntPtr pnaxlocPtr   = IntPtr.Zero;
            IntPtr pnaylocPtr   = IntPtr.Zero;
            IntPtr pnawidthPtr  = IntPtr.Zero;
            int    _Result      = Natives.rchaExtract(rcha.Pointer, out pnaindexPtr, out pnascorePtr, out psatextPtr, out pnasamplePtr, out pnaxlocPtr, out pnaylocPtr, out pnawidthPtr);

            if (pnaindexPtr == IntPtr.Zero)
            {
                pnaindex = null;
            }
            else
            {
                pnaindex = new Numa(pnaindexPtr);
            };
            if (pnascorePtr == IntPtr.Zero)
            {
                pnascore = null;
            }
            else
            {
                pnascore = new Numa(pnascorePtr);
            };
            if (psatextPtr == IntPtr.Zero)
            {
                psatext = null;
            }
            else
            {
                psatext = new Sarray(psatextPtr);
            };
            if (pnasamplePtr == IntPtr.Zero)
            {
                pnasample = null;
            }
            else
            {
                pnasample = new Numa(pnasamplePtr);
            };
            if (pnaxlocPtr == IntPtr.Zero)
            {
                pnaxloc = null;
            }
            else
            {
                pnaxloc = new Numa(pnaxlocPtr);
            };
            if (pnaylocPtr == IntPtr.Zero)
            {
                pnayloc = null;
            }
            else
            {
                pnayloc = new Numa(pnaylocPtr);
            };
            if (pnawidthPtr == IntPtr.Zero)
            {
                pnawidth = null;
            }
            else
            {
                pnawidth = new Numa(pnawidthPtr);
            };

            return(_Result);
        }