|
|||||||||||||||||||||||||||||
How to get a Bitmap from a Visualpublic void SaveImage(Visual visual, int width, int height, string filePath) { RenderTargetBitmap bitmap = new RenderTargetBitmap(width, height, 96, 96, PixelFormats.Pbgra32); bitmap.Render(visual); PngBitmapEncoder image = new PngBitmapEncoder(); image.Frames.Add(BitmapFrame.Create(bitmap)); using (Stream fs = File.Create(filePath)) { image.Save(fs); } }
Last modified: 2009-07-13 11:28:57
Copyright (c) by Christian Moser, 2011.
Comments on this articleShow all comments
|
|||||||||||||||||||||||||||||