Beispiel #1
0
        public void Initialize()
        {
            bmp = new Bitmap(DefaultWidth, DefaultHeight);

            for (int y = 0; y < DefaultWidth; y++)
                for (int x = 0; x < DefaultHeight; x++)
                    bmp.Set(x, y, new Color(DefaultColorAsInt));
        }
        public FourWayColorSwapingCrawler(Bitmap bitmap, TolerantColorComparer colorComparer)
        {
            if (bitmap == null)
                throw new ArgumentNullException(nameof(bitmap));
            if (colorComparer == null)
                throw new ArgumentNullException(nameof(colorComparer));

            Bitmap = bitmap;
            ColorComparer = colorComparer;
            Scanlines = new Stack<ScanlineData>(Math.Max(bitmap.Width, bitmap.Height));
        }
Beispiel #3
0
        /// <summary>
        /// Created a ManagedBitmap from a System.Drawing.Bitmap.
        /// </summary>
        public static Bitmap FromSystemBitmap(System.Drawing.Bitmap systemBitmap)
        {
            if (systemBitmap == null)
                throw new ArgumentNullException(nameof(systemBitmap));

            Bitmap managed = new Bitmap(systemBitmap.Width, systemBitmap.Height);
            using (var correctFormatBitmap = systemBitmap.ToDifferentPixelFormat(ValidPixelFormat))
            {
                var bmpData = correctFormatBitmap.LockBits(managed.BoundingRectangle.ToSystemRectangle(), System.Drawing.Imaging.ImageLockMode.ReadOnly, correctFormatBitmap.PixelFormat);
                Marshal.Copy(bmpData.Scan0, managed._PixelArray, 0, managed._PixelArray.Length);
                correctFormatBitmap.UnlockBits(bmpData);
            }

            return managed;
        }
Beispiel #4
0
 /// <summary>
 /// Creates a deep copy of this Bitmap.
 /// </summary>
 public Bitmap Clone()
 {
     var clone = new Bitmap(Width, Height);
     Array.Copy(_PixelArray, clone._PixelArray, _PixelArray.Length);
     return clone;
 }