Example #1
0
        public void Merge(MonochromeBitmap source, MonochromeBitmap destination, Point location)
        {
            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }
            if (destination == null)
            {
                throw new ArgumentNullException(nameof(destination));
            }

            var maxX = Math.Min(location.X + source.Width, destination.Width);
            var maxY = Math.Min(location.Y + source.Height, destination.Height);

            for (var x = Math.Max(location.X, 0); x < maxX; x++)
            {
                for (var y = Math.Max(location.Y, 0); y < maxY; y++)
                {
                    if (!destination[x, y])
                    {
                        destination[x, y] = source[x - location.X, y - location.Y];
                    }
                }
            }
        }
Example #2
0
        public void Merge(MonochromeBitmap bitmap, Point location, IMergeMethod mergeMethod)
        {
            if (bitmap == null)
            {
                return;
            }
            if (mergeMethod == null)
            {
                throw new ArgumentNullException(nameof(mergeMethod));
            }

            mergeMethod.Merge(bitmap, this, location);
        }
Example #3
0
        public void Merge(MonochromeBitmap source, MonochromeBitmap destination, Point location)
        {
            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }
            if (destination == null)
            {
                throw new ArgumentNullException(nameof(destination));
            }

            var maxX = Math.Min(location.X + source.Width, destination.Width);
            var maxY = Math.Min(location.Y + source.Height, destination.Height);

            for (var x = Math.Max(location.X, 0); x < maxX; x++)
            {
                for (var y = Math.Max(location.Y, 0); y < maxY; y++)
                {
                    if (source[x - location.X, y - location.Y])
                    {
                        destination[x, y] = true;
                        for (var ox = -1; ox <= 1; ox++)
                        {
                            for (var oy = -1; oy <= 1; oy++)
                            {
                                if (!(ox == 0 && oy == 0))
                                {
                                    var dx = x + ox;
                                    var dy = y + oy;
                                    if (dx < 0 || dy < 0 || dx >= destination.Width || dy >= destination.Height)
                                    {
                                        continue;
                                    }

                                    var sx = dx - location.X;
                                    var sy = dy - location.Y;

                                    if (source[sx, sy] || !destination[dx, dy])
                                    {
                                        continue;
                                    }

                                    destination[dx, dy] = false;
                                }
                            }
                        }
                    }
                }
            }
        }
Example #4
0
        public MonochromeBitmap(MonochromeBitmap bitmap, int width, int height) : this(width, height)
        {
            if (bitmap == null)
            {
                throw new ArgumentNullException(nameof(bitmap));
            }

            for (var x = Math.Min(Width, bitmap.Width) - 1; x >= 0; x--)
            {
                for (var y = Math.Min(Height, bitmap.Height) - 1; y >= 0; y--)
                {
                    SetPixel(x, y, bitmap.GetPixel(x, y));
                }
            }
        }
Example #5
0
 public void MergeOverride(MonochromeBitmap bitmap, Point location)
 {
     Merge(bitmap, location, MergeMethods.Override);
 }