Friday, 15 April 2011

c# - How to store System.Windows.Controls.Image to local disk -


How can I store on a System.Windows.Controls.Image disk that says: \ data \ 1 .jpg: thanks to

You might try some on the pattern of this method:

Private Zero SaveImageToJPEG (Image ImageToSave, string location) {RenderTargetBitmap renderTargetBitmap = New RenderTargetBitmap ((int) ImageToSave.Source.Width, (int) ImageToSave.Source.Height, 100, 100, PixelFormats.Default) ; RenderTargetBitmap.Render (ImageToSave); JPGbitmap encoder JPEGBitMapEncoder = new JPEGBitMapEncoder (); JpegBitmapEncoder.Frames.Add (BitmapFrame.Create (renderTargetBitmap)); (Filestream filestream = new filestream (location, Flamemode.)) Using {jpegBitmapEncoder.Save (fileStream); FileStream.Flush (); FileStream.Close (); }}

To get what you want, you may need to mess with the sizes in RenderTargetBitmap, but she should get a job. You can also use different encoders as compared to the JPEGMapmap encoder.


No comments:

Post a Comment