public void ApplyMatches(IEnumerable <SourceAndMatch> matches)
 {
     _target.Lock();
     foreach (var imageMatch in matches)
     {
         WriteSourceAndFill(imageMatch);
     }
     _target.Unlock();
 }
        private void WriteSourceAndFill(SourceAndMatch match)
        {
            FastBitmap.FastBitmap fillImage = new FastBitmap.FastBitmap(match.ReplacementImage);

            fillImage.Lock();

            ImageManipulationInfo hole = match.SourceSegment;

            for (int xOffset = 0; xOffset < hole.Width; xOffset++)
            {
                for (int yOffset = 0; yOffset < hole.Height; yOffset++)
                {
                    Color holeColor = _target.GetPixel(hole.StartX + xOffset, hole.StartY + yOffset);
                    Color fillColor = fillImage.GetPixel(xOffset, yOffset);
                    _newImage.SetPixel(hole.StartX + xOffset, hole.StartY + yOffset, GetNewColor(holeColor, fillColor));
                }
            }

            fillImage.Unlock();
        }
        public static Bitmap ToBitmap(this FlatArray2DArray <int> array)
        {
            FastBitmap.FastBitmap convolutedBitmap = new FastBitmap.FastBitmap(new Bitmap(array.Width, array.Height));
            convolutedBitmap.Lock();

            for (int y = 0; y < array.Height; y++)
            {
                for (int x = 0; x < array.Width; x++)
                {
                    // Get convolution value
                    int value = array[x, y];

                    value = value < 0 ? 0 : value;
                    value = value > 255 ? 255 : value;

                    // Set convolution value
                    convolutedBitmap.SetPixel(x, y, Color.FromArgb(value, value, value));
                }
            }

            convolutedBitmap.Unlock();

            return(convolutedBitmap.ToBitmap());
        }