Quantcast
Channel: Visual C# forum
Viewing all articles
Browse latest Browse all 31927

Problem with SavefileDialog process

$
0
0

this relates to the following post

http://social.msdn.microsoft.com/Forums/vstudio/en-US/90ca521e-3eec-466c-ad66-99f3e6052f4b/putting-an-image-from-file-into-a-picturebox?forum=csharpgeneral

After implementing this method, i find that the savefiledialog misbehaves when saving out. It appears to go through the process but hangs and does not show any dialogs to say why, even though they are enabled.

i have removed the line that copies my image (Bitmap) to the picturebox.image :-

 Graphics g = Graphics.FromImage(sheet);
                Destination = new Rectangle(x, y, img.Width, img.Height);
                fillregion = new Region(Destination);
                TextureBrush textureBrush = new TextureBrush(img);
                g.FillRegion(textureBrush, fillregion);
                //pictureBox1.Image = sheet;
                g.Dispose();

and replaced it with a preloaded image in the picturebox and the alerts on savefiledialog work again ??

i am using the following to save :-

if (pictureBox1.Image != null)
            {

                SaveFileDialog SaveFile = new SaveFileDialog();

                SaveFile.Title = "Save Image file";
                SaveFile.CheckPathExists = true;
                SaveFile.CheckFileExists = false;
                SaveFile.CreatePrompt = true;
                SaveFile.OverwritePrompt = true;
                SaveFile.InitialDirectory = path;
                SaveFile.DefaultExt = ext;
                SaveFile.Filter = "Graphics Files |*.bmp;*.png;*.gif;*.jpg | All Files | *.*";

                if (SaveFile.ShowDialog() == DialogResult.OK)
                {

                    ImageFormat imagetype = null;

                    switch (ext)
                    {
                        case ".bmp":
                            imagetype = ImageFormat.Bmp;
                            break;
                        case ".png":
                            imagetype = ImageFormat.Png;
                            break;
                        case ".gif":
                            imagetype = ImageFormat.Gif;
                            break;
                        case ".jpg":
                            imagetype = ImageFormat.Jpeg;
                            break;
                        default:
                            MessageBox.Show("Unsupported FileFormat");
                            break;
                    }

                    pictureBox1.Image.Save(SaveFile.FileName, imagetype);
                   
                }

            }
            else
            {
                MessageBox.Show("Load something to save ?");
            }

Does anyone have any ideas as to why using my Bitmap causes this to lock out the system. I can see nothing in the code or IDE to say there is a problem.

TIA


Viewing all articles
Browse latest Browse all 31927

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>