コード例 #1
0
ファイル: SavePicture.cs プロジェクト: taving/BenMAP-CE
        public String SaveAs(String DefaultFileName, ColorBlendControl _colorBlendControl)
        {
            _saveFileDialog.Filter =
                "Jpeg Format (*.jpg)|*.jpg|" +
                "PNG Format (*.png)|*.png|" +
                "Gif Format (*.gif)|*.gif|" +
                "Tiff Format (*.tif)|*.tif|" +
                "Bmp Format (*.bmp)|*.bmp";

            if (DefaultFileName != null && DefaultFileName.Length > 0)
            {
                String ext = System.IO.Path.GetExtension(DefaultFileName).ToLower();
                switch (ext)
                {
                case ".png": _saveFileDialog.FilterIndex = 2; break;

                case ".gif": _saveFileDialog.FilterIndex = 3; break;

                case ".jpeg": _saveFileDialog.FilterIndex = 1; break;

                case ".jpg": _saveFileDialog.FilterIndex = 1; break;

                case ".tiff": _saveFileDialog.FilterIndex = 4; break;

                case ".tif": _saveFileDialog.FilterIndex = 4; break;

                case ".bmp": _saveFileDialog.FilterIndex = 5; break;
                }
                if (DefaultFileName.Length > ext.Length)
                {
                    _saveFileDialog.FileName = DefaultFileName;
                }
            }

            if (_saveFileDialog.ShowDialog() == DialogResult.OK)
            {
                Stream myStream = _saveFileDialog.OpenFile();
                if (myStream != null)
                {
                    ImageFormat format = ImageFormat.Png;
                    switch (_saveFileDialog.FilterIndex)
                    {
                    case 1: format = ImageFormat.Jpeg; break;

                    case 2: format = ImageFormat.Png; break;

                    case 3: format = ImageFormat.Gif; break;

                    case 4: format = ImageFormat.Tiff; break;

                    case 5: format = ImageFormat.Bmp; break;
                    }

                    long   a         = myStream.Length;
                    Bitmap _bmpBlend = _colorBlendControl.DrawImage();
                    a = myStream.Length;



                    myStream.Close();
                    return(_saveFileDialog.FileName);
                }
            }
            return("");
        }
コード例 #2
0
ファイル: SavePicture.cs プロジェクト: taving/BenMAP-CE
 public SavePicture(ColorBlendControl colorBlendControl)
 {
     _colorBlendControl = colorBlendControl;
 }