void btnExport_Click(object sender, EventArgs e)
        {
            if (_selection.Width == 0f || _selection.Height == 0f)
            {
                MessageBox.Show("Can't export, selection is empty.");
                return;
            }

            SaveFileDialog sfd = new SaveFileDialog();

            sfd.Filter          = "Png Files (*.png)|*.png";
            sfd.CheckPathExists = true;
            if (sfd.ShowDialog() == DialogResult.OK)
            {
                var cropRect = new RectF(
                    _selection.X * _bitmap.PixelWidth,
                    _selection.Y * _bitmap.PixelHeight,
                    _selection.Width * _bitmap.PixelWidth,
                    _selection.Height * _bitmap.PixelHeight);
                _bitmap.SaveAsPng(sfd.FileName, new PngOptions {
                    SourceRect = new ImageRect(cropRect.Round())
                });
                _selection = new RectF(1f, 1f);
                pictureBox1.Invalidate();
            }
        }
        void btnExport_Click(object sender, EventArgs e)
        {
            SaveFileDialog sfd = new SaveFileDialog();

            sfd.Filter          = "Png Files (*.png)|*.png";
            sfd.CheckPathExists = true;
            if (sfd.ShowDialog() == DialogResult.OK)
            {
                _bitmap.SaveAsPng(sfd.FileName, null);
            }
        }
示例#3
0
        void ExportImage(object sender, RoutedEventArgs e)
        {
            SaveFileDialog sfd = new SaveFileDialog();

            sfd.Filter          = "Png Files (*.png)|*.png";
            sfd.CheckPathExists = true;
            if (sfd.ShowDialog().Value)
            {
                _bitmap.SaveAsPng(sfd.FileName, null);
            }
        }
示例#4
0
        void btnExport_Click(object sender, EventArgs e)
        {
            SaveFileDialog sfd = new SaveFileDialog();

            sfd.Filter          = "Png Files (*.png)|*.png";
            sfd.CheckPathExists = true;
            if (sfd.ShowDialog() == DialogResult.OK)
            {
                _bitmap.SaveAsPng(sfd.FileName, null);
                _selection = new RectF(1f, 1f);
                pictureBox1.Invalidate();
            }
        }
        void ExportImage(object sender, RoutedEventArgs e)
        {
            if (_selection.Width == 0 || _selection.Height == 0)
            {
                MessageBox.Show("Can't export, selection is empty.");
                return;
            }

            SaveFileDialog sfd = new SaveFileDialog();

            sfd.Filter          = "Png Files (*.png)|*.png";
            sfd.CheckPathExists = true;
            if (sfd.ShowDialog().Value)
            {
                var cropRect = ((RectD)_selection).Round();
                _bitmap.SaveAsPng(sfd.FileName, new PngOptions {
                    SourceRect = new ImageRect(cropRect)
                });

                _selection = new Rect(0, 0, _bitmap.PixelWidth, _bitmap.PixelHeight);
                UpdateMask();
            }
        }