Ejemplo n.º 1
0
        // pdfio2.c (943, 1)
        // l_generateCIData(fname, type, quality, ascii85, pcid) as int
        // l_generateCIData(const char *, l_int32, l_int32, l_int32, L_COMP_DATA **) as l_ok
        ///  <summary>
        /// (1) This can be used for both PostScript and pdf.<para/>
        ///
        /// (1) Set ascii85:
        /// ~ 0 for binary data (not permitted in PostScript)
        /// ~ 1 for ascii85 (5 for 4) encoded binary data<para/>
        ///
        /// (2) This attempts to compress according to the requested type.
        /// If this can't be done, it falls back to ordinary flate encoding.<para/>
        ///
        /// (3) This differs from l_generateCIDataPdf(), which determines
        /// the format and attempts to generate the CID without transcoding.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/l_generateCIData/*"/>
        ///  <param name="fname">[in] - </param>
        ///  <param name="type">[in] - L_G4_ENCODE, L_JPEG_ENCODE, L_FLATE_ENCODE, L_JP2K_ENCODE</param>
        ///  <param name="quality">[in] - used for jpeg only 0 for default (75)</param>
        ///  <param name="ascii85">[in] - 0 for binary 1 for ascii85-encoded</param>
        ///  <param name="pcid">[out] - compressed data</param>
        ///   <returns>0 if OK, 1 on error</returns>
        public static int l_generateCIData(
            String fname,
            int type,
            int quality,
            int ascii85,
            out L_Compressed_Data pcid)
        {
            if (fname == null)
            {
                throw new ArgumentNullException("fname cannot be Nothing");
            }

            IntPtr pcidPtr = IntPtr.Zero;
            int    _Result = Natives.l_generateCIData(fname, type, quality, ascii85, out pcidPtr);

            if (pcidPtr == IntPtr.Zero)
            {
                pcid = null;
            }
            else
            {
                pcid = new L_Compressed_Data(pcidPtr);
            };

            return(_Result);
        }
Ejemplo n.º 2
0
        // pdfio2.c (1039, 1)
        // pixGenerateCIData(pixs, type, quality, ascii85, pcid) as int
        // pixGenerateCIData(PIX *, l_int32, l_int32, l_int32, L_COMP_DATA **) as l_ok
        ///  <summary>
        /// (1) Set ascii85:
        /// ~ 0 for binary data (not permitted in PostScript)
        /// ~ 1 for ascii85 (5 for 4) encoded binary data
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/pixGenerateCIData/*"/>
        ///  <param name="pixs">[in] - 8 or 32 bpp, no colormap</param>
        ///  <param name="type">[in] - L_G4_ENCODE, L_JPEG_ENCODE, L_FLATE_ENCODE</param>
        ///  <param name="quality">[in] - used for jpeg only 0 for default (75)</param>
        ///  <param name="ascii85">[in] - 0 for binary 1 for ascii85-encoded</param>
        ///  <param name="pcid">[out] - compressed data</param>
        ///   <returns>0 if OK, 1 on error</returns>
        public static int pixGenerateCIData(
            Pix pixs,
            int type,
            int quality,
            int ascii85,
            out L_Compressed_Data pcid)
        {
            if (pixs == null)
            {
                throw new ArgumentNullException("pixs cannot be Nothing");
            }

            IntPtr pcidPtr = IntPtr.Zero;
            int    _Result = Natives.pixGenerateCIData(pixs.Pointer, type, quality, ascii85, out pcidPtr);

            if (pcidPtr == IntPtr.Zero)
            {
                pcid = null;
            }
            else
            {
                pcid = new L_Compressed_Data(pcidPtr);
            };

            return(_Result);
        }
Ejemplo n.º 3
0
        // pdfio2.c (1476, 1)
        // l_CIDataDestroy(pcid) as Object
        // l_CIDataDestroy(L_COMP_DATA **) as void
        ///  <summary>
        /// l_CIDataDestroy()
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/l_CIDataDestroy/*"/>
        ///  <param name="pcid">[in,out] - will be set to null before returning</param>
        public static void l_CIDataDestroy(
            ref L_Compressed_Data pcid)
        {
            IntPtr pcidPtr = IntPtr.Zero;   if (pcid != null)

            {
                pcidPtr = pcid.Pointer;
            }

            Natives.l_CIDataDestroy(ref pcidPtr);
            if (pcidPtr == IntPtr.Zero)
            {
                pcid = null;
            }
            else
            {
                pcid = new L_Compressed_Data(pcidPtr);
            };
        }
Ejemplo n.º 4
0
        // pdfio2.c (1427, 1)
        // cidConvertToPdfData(cid, title, pdata, pnbytes) as int
        // cidConvertToPdfData(L_COMP_DATA *, const char *, l_uint8 **, size_t *) as l_ok
        ///  <summary>
        /// (1) Caller must not destroy the cid.  It is absorbed in the
        /// lpd and destroyed by this function.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/cidConvertToPdfData/*"/>
        ///  <param name="cid">[in] - compressed image data -- of jp2k image</param>
        ///  <param name="title">[in][optional] - pdf title can be NULL</param>
        ///  <param name="pdata">[out] - output pdf data for image</param>
        ///  <param name="pnbytes">[out] - size of output pdf data</param>
        ///   <returns>0 if OK, 1 on error</returns>
        public static int cidConvertToPdfData(
            L_Compressed_Data cid,
            String title,
            out Byte[] pdata,
            out uint pnbytes)
        {
            if (cid == null)
            {
                throw new ArgumentNullException("cid cannot be Nothing");
            }

            IntPtr pdataPtr = IntPtr.Zero;
            int    _Result  = Natives.cidConvertToPdfData(cid.Pointer, title, out pdataPtr, out pnbytes);

            Byte[] pdataGen = new Byte[pnbytes];

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

            pdata = pdataGen;
            return(_Result);
        }
Ejemplo n.º 5
0
        // pdfio2.c (520, 1)
        // l_generateCIDataForPdf(fname, pix, quality, pcid) as int
        // l_generateCIDataForPdf(const char *, PIX *, l_int32, L_COMP_DATA **) as l_ok
        ///  <summary>
        /// (1) You must set either filename or pix.<para/>
        ///
        /// (2) Given an image file and optionally a pix raster of that data,
        /// this provides a CID that is compatible with PDF, preferably
        /// without transcoding.<para/>
        ///
        /// (3) The pix is included for efficiency, in case transcoding
        /// is required and the pix is available to the caller.<para/>
        ///
        /// (4) We don't try to open files named "stdin" or "-" for Tesseract
        /// compatibility reasons. We may remove this restriction
        /// in the future.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/l_generateCIDataForPdf/*"/>
        ///  <param name="fname">[in][optional] - can be null</param>
        ///  <param name="pix">[in][optional] - can be null</param>
        ///  <param name="quality">[in] - for jpeg if transcoded 75 is standard</param>
        ///  <param name="pcid">[out] - compressed data</param>
        ///   <returns>0 if OK, 1 on error</returns>
        public static int l_generateCIDataForPdf(
            String fname,
            Pix pix,
            int quality,
            out L_Compressed_Data pcid)
        {
            IntPtr pixPtr = IntPtr.Zero;    if (pix != null)
            {
                pixPtr = pix.Pointer;
            }
            IntPtr pcidPtr = IntPtr.Zero;
            int    _Result = Natives.l_generateCIDataForPdf(fname, pixPtr, quality, out pcidPtr);

            if (pcidPtr == IntPtr.Zero)
            {
                pcid = null;
            }
            else
            {
                pcid = new L_Compressed_Data(pcidPtr);
            };

            return(_Result);
        }