コード例 #1
0
        private void CalculateRectanglesOfDifferences(ComparableBitmap[] bitmap1, ComparableBitmap[] bitmap2)
        {
            if ((bitmap1 == null) || (bitmap2 == null))
            {
                return;
            }

            List <RectanglesWithSimilarity> rectangles = new List <RectanglesWithSimilarity>();
            float similarity;

            for (int i = 0; i < bitmap1.Length; i++)
            {
                if (_highlightStop)
                {
                    return;
                }
                similarity = Comparator.Similarity(bitmap1[i].GrayscaleData, bitmap2[i].GrayscaleData);
                if (similarity < m_options.resultsOptions.DifferenceThreshold)
                {
                    rectangles.Add(new RectanglesWithSimilarity(bitmap1[i].Rect, similarity));
                }
            }

            if (m_options.resultsOptions.NotHighlightIfFragmentsMoreThan && rectangles.Count > m_options.resultsOptions.NotHighlightMaxFragments)
            {
                return;
            }

            if (!m_options.resultsOptions.HighlightAllDifferences)
            {
                if (HighlightCompleteEvent != null)
                {
                    HighlightCompleteEvent((from rect in rectangles
                                            orderby rect.similarity descending
                                            select rect.rectangle).Take(m_options.resultsOptions.MaxFragmentsForHighlight).ToList());
                }
            }

            if (HighlightCompleteEvent != null)
            {
                HighlightCompleteEvent((from rect in rectangles
                                        select rect.rectangle).ToList());
            }
        }