Exemplo n.º 1
0
        /// <summary>
        /// Creates an <see cref="EditableBitmap"/> as a view on a section of an existing <see cref="EditableBitmap"/>.
        /// </summary>
        /// <param name="source"></param>
        /// <param name="viewArea"></param>
        protected EditableBitmap(EditableBitmap source, Rectangle viewArea)
        {
            owner           = source;
            pixelFormatSize = source.pixelFormatSize;
            byteArray       = source.byteArray;
            byteArray.AddReference();
            stride = source.stride;

            try {
                startOffset = source.startOffset + (stride * viewArea.Y) + (viewArea.X * pixelFormatSize);
                bitmap      = new Bitmap(viewArea.Width, viewArea.Height, stride, source.Bitmap.PixelFormat,
                                         (IntPtr)(((int)byteArray.bitPtr) + startOffset));
            }
            finally {
                if (bitmap == null)
                {
                    byteArray.ReleaseReference();
                }
            }
        }
Exemplo n.º 2
0
        public Bitmap FloodFill(Bitmap bmp, Point pt)
        {
            if (bmp == null)
            {
                return(null);
            }

            Rectangle imageRect = new Rectangle(0, 0, bmp.Width, bmp.Height);

            if (!imageRect.Contains(pt))
            {
                return(null);
            }

            EditableBitmap editBmp = new EditableBitmap(bmp);

            this.bitmap = editBmp;
            PrepareForFloodFill(pt);
            DoFloodFill(pt);
            this.bitmap = null;
            return(editBmp.Bitmap);
        }