Ejemplo n.º 1
0
        public void Init()
        {
            _image = new Image(_width, _height, ImageBaseType.Rgb) {
            {new Layer("test", ImageType.Rgb), 0}};

              _drawable = _image.ActiveDrawable;
              _selection = _image.Selection;
        }
Ejemplo n.º 2
0
        public SelectionMask(Selection selection)
        {
            bool selectionNonEmpty;
            _originBounds = selection.Bounds(out selectionNonEmpty);
            if (!selectionNonEmpty)
            {
                _mask = null;
                return;
            }

            _mask = new bool[_originBounds.Width,_originBounds.Height];
            var selRgn = new PixelRgn(selection, _originBounds, false, false);
            var iterator = new RegionIterator(selRgn);

            iterator.ForEach(pixel =>
                {
                    if (pixel.Red > 128)
                    {
                        _area++;
                        _mask[pixel.X - _originBounds.X1, pixel.Y - _originBounds.Y1] = true;
                    }
                });
        }