Click here to Skip to main content
15,886,137 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Here is my code............Hope i can get solution from experts
i want to generate id for image and save it in c:\ folder without opening dialogue box..is is Possible?

C#
private void SaveImage_Click(object sender, RoutedEventArgs e)
        {
            //string strImageID = getImageID();
            // Gets the current captured raw bitmap
            var rawImage = SelectedSnapshot;

            // If image is selected in the Snapshots ListBox then set it as a save target
            if (Snapshots.SelectedItem != null)
                rawImage = (WriteableBitmap)Snapshots.SelectedItem;

            if (rawImage != null)
            {
                // Init the Save File Dialog
               SaveFileDialog saveDialog = new SaveFileDialog();
                saveDialog.GetType().GetMethod("set_DefaultFileName").Invoke(saveDialog, new object[] { "FileName.jpg" });
               saveDialog.Filter = "Image Files (*.jpg, *.jpeg)|*.jpg;*.jpeg|All Files (*.*)|*.*";
                saveDialog.DefaultExt = ".jpg";
               saveDialog.FilterIndex = 1;




                // Show save dialog to the user
                if ((bool)saveDialog.ShowDialog())
                {
                    using (Stream stream = saveDialog.OpenFile())
                    {
                        // Convert raw captured bitmap to the image that Image Tools understand with the extension method
                        var image = rawImage.ToImage();
                        // Declare jpeg encoder
                        var encoder = new JpegEncoder();
                        // Set the image quality
                        encoder.Quality = 90;


                        // Finally encode raw bitmap and save it as a jpg image
                       encoder.Encode(image, stream);
                       // Close the stream
                        stream.Close();
                    }
                }
           }
        }
Posted
Updated 14-Sep-13 1:44am
v2
Comments
[no name] 14-Sep-13 7:30am    
"Here is my code:, yes very nice.
"Hope i can get solution".... to get some sort of a "solution" you would first have to ask some sort of a question or describe some sort of a problem. Do you have any idea how expensive the ingredients for mind reading potions are?
ParameshReddy 14-Sep-13 7:44am    
i want to auto generate id for uploaded image and save it in some c:\ folder without opening dialogue box..is it Possible?
[no name] 14-Sep-13 7:54am    
Great question.... yes it is possible.
ParameshReddy 18-Sep-13 8:34am    
please give me some hint with code...Thanks
Member 10492680 31-Jan-14 1:19am    
I Have same problem..is their any solution..?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900