public virtual String ExtractAndCompareImages(String outputPdf, String cmpPdf, String outputPath, String fuzzValue
                                                      )
        {
            String outImgPath = outputPath + "out/";
            String cmpImgPath = outputPath + "cmp/";

            ITextTest.CreateOrClearDestinationFolder(outImgPath);
            ITextTest.CreateOrClearDestinationFolder(cmpImgPath);
            IDictionary <int, CleanUpImagesCompareTool.PageImageObjectsPaths> cmpObjectDatas = ExtractImagesFromPdf(cmpPdf
                                                                                                                    , cmpImgPath);
            IDictionary <int, CleanUpImagesCompareTool.PageImageObjectsPaths> outObjectDatas = ExtractImagesFromPdf(outputPdf
                                                                                                                    , outImgPath);

            if (cmpObjectDatas.Count != outObjectDatas.Count)
            {
                return("Number of pages differs in out and cmp pdf documents:\nout = " + outObjectDatas.Count + "\ncmp = "
                       + cmpObjectDatas.Count);
            }
            try {
                foreach (int page in cmpObjectDatas.Keys)
                {
                    InitializeIgnoredObjectPath(cmpObjectDatas.Get(page), outObjectDatas.Get(page));
                }
            }
            catch (Exception e) {
                return(e.Message);
            }
            String[] cmpImages = FileUtil.ListFilesInDirectory(cmpImgPath, true);
            String[] outImages = FileUtil.ListFilesInDirectory(outImgPath, true);
            JavaUtil.Sort(cmpImages);
            JavaUtil.Sort(outImages);
            if (cmpImages.Length != outImages.Length)
            {
                return("Number of images should be the same!");
            }
            StringBuilder resultErrorMessage = new StringBuilder();

            try {
                for (int i = 0; i < cmpImages.Length; i++)
                {
                    String diffImage = outputPath + "diff_" + new FileInfo(cmpImages[i]).Name;
                    String errorText = CompareImages(outImages[i], cmpImages[i], diffImage, fuzzValue);
                    if (errorText != null)
                    {
                        resultErrorMessage.Append(errorText);
                    }
                }
            }
            catch (Exception e) {
                return(e.Message);
            }
            return(resultErrorMessage.ToString());
        }
Пример #2
0
        private static IList <ImageData> ProcessGifImageAndExtractFrames(int[] frameNumbers, GifImageData image)
        {
            JavaUtil.Sort(frameNumbers);
            GifImageHelper.ProcessImage(image, frameNumbers[frameNumbers.Length - 1] - 1);
            IList <ImageData> frames = new List <ImageData>();

            foreach (int frame in frameNumbers)
            {
                frames.Add(image.GetFrames()[frame - 1]);
            }
            return(frames);
        }
Пример #3
0
        /// <exception cref="System.IO.IOException"/>
        protected internal virtual void CreateNewGlyphTables()
        {
            newLocaTable = new int[locaTable.Length];
            int[] activeGlyphs = new int[glyphsInList.Count];
            for (int k = 0; k < activeGlyphs.Length; ++k)
            {
                activeGlyphs[k] = (int)glyphsInList[k];
            }
            JavaUtil.Sort(activeGlyphs);
            int glyfSize = 0;

            foreach (int glyph in activeGlyphs)
            {
                glyfSize += locaTable[glyph + 1] - locaTable[glyph];
            }
            glyfTableRealSize = glyfSize;
            glyfSize          = glyfSize + 3 & ~3;
            newGlyfTable      = new byte[glyfSize];
            int glyfPtr  = 0;
            int listGlyf = 0;

            for (int k = 0; k < newLocaTable.Length; ++k)
            {
                newLocaTable[k] = glyfPtr;
                if (listGlyf < activeGlyphs.Length && activeGlyphs[listGlyf] == k)
                {
                    ++listGlyf;
                    newLocaTable[k] = glyfPtr;
                    int start = locaTable[k];
                    int len   = locaTable[k + 1] - start;
                    if (len > 0)
                    {
                        rf.Seek(tableGlyphOffset + start);
                        rf.ReadFully(newGlyfTable, glyfPtr, len);
                        glyfPtr += len;
                    }
                }
            }
        }
Пример #4
0
        /// <summary>Build a PdfDictionary containing the name tree</summary>
        /// <returns>PdfDictionary containing the name tree</returns>
        public virtual PdfDictionary BuildTree()
        {
            String[] names = new String[items.Count];
            names = items.Keys.ToArray(names);
            JavaUtil.Sort(names);
            if (names.Length <= NODE_SIZE)
            {
                PdfDictionary dic = new PdfDictionary();
                PdfArray      ar  = new PdfArray();
                foreach (String name in names)
                {
                    ar.Add(new PdfString(name, null));
                    ar.Add(items.Get(name));
                }
                dic.Put(PdfName.Names, ar);
                return(dic);
            }
            int skip = NODE_SIZE;

            PdfDictionary[] kids = new PdfDictionary[(names.Length + NODE_SIZE - 1) / NODE_SIZE];
            for (int k = 0; k < kids.Length; ++k)
            {
                int           offset = k * NODE_SIZE;
                int           end    = Math.Min(offset + NODE_SIZE, names.Length);
                PdfDictionary dic    = new PdfDictionary();
                PdfArray      arr    = new PdfArray();
                arr.Add(new PdfString(names[offset], null));
                arr.Add(new PdfString(names[end - 1], null));
                dic.Put(PdfName.Limits, arr);
                arr = new PdfArray();
                for (; offset < end; ++offset)
                {
                    arr.Add(new PdfString(names[offset], null));
                    arr.Add(items.Get(names[offset]));
                }
                dic.Put(PdfName.Names, arr);
                dic.MakeIndirect(catalog.GetDocument());
                kids[k] = dic;
            }
            int top = kids.Length;

            while (true)
            {
                if (top <= NODE_SIZE)
                {
                    PdfArray arr = new PdfArray();
                    for (int i = 0; i < top; ++i)
                    {
                        arr.Add(kids[i]);
                    }
                    PdfDictionary dic = new PdfDictionary();
                    dic.Put(PdfName.Kids, arr);
                    return(dic);
                }
                skip *= NODE_SIZE;
                int tt = (names.Length + skip - 1) / skip;
                for (int i = 0; i < tt; ++i)
                {
                    int           offset = i * NODE_SIZE;
                    int           end    = Math.Min(offset + NODE_SIZE, top);
                    PdfDictionary dic    = (PdfDictionary) new PdfDictionary().MakeIndirect(catalog.GetDocument());
                    PdfArray      arr    = new PdfArray();
                    arr.Add(new PdfString(names[i * skip], null));
                    arr.Add(new PdfString(names[Math.Min((i + 1) * skip, names.Length) - 1], null));
                    dic.Put(PdfName.Limits, arr);
                    arr = new PdfArray();
                    for (; offset < end; ++offset)
                    {
                        arr.Add(kids[offset]);
                    }
                    dic.Put(PdfName.Kids, arr);
                    kids[i] = dic;
                }
                top = tt;
            }
        }
Пример #5
0
 static Tokeniser()
 {
     // replaces null character
     JavaUtil.Sort(notCharRefCharsSorted);
 }
Пример #6
0
 static Tokeniser()
 {
     JavaUtil.Sort(notCharRefCharsSorted);
 }