Esempio n. 1
0
        public Bitmap GetSelection()
        {
            var bounds = new RectangleF(new PointF(0, 0), Image.Size);

            if (Selection != null)
            {
                bounds = Selection.Path.GetBounds();
            }
            var bmp = new Bitmap((int)bounds.Width, (int)bounds.Height);

            using (var g = Graphics.FromImage(bmp))
            {
                g.TranslateTransform(-bounds.X, -bounds.Y);
                if (Selection != null)
                {
                    g.Clip = new Region(Selection.Path);
                }
                if (SelectedLayer is MaskedLayer)
                {
                    (SelectedLayer as MaskedLayer).ColorMatrix.Matrix33 = 1;
                }
                SelectedLayer.Paint(g);
                if (SelectedLayer is MaskedLayer)
                {
                    (SelectedLayer as MaskedLayer).ColorMatrix.Matrix33 = 0.5f;
                }
            }
            return(bmp);
        }