Hello, I'm trying to save a wpf control to file, but I'm applying a PixelShader effect to it, and when I try to save, the saved image is entirely white, black or red... deppends on the parameters of the effect.
I'm using the code here: http://stackoverflow.com/questions/59958/wpf-programmatic-binding-on-a-bitmapeffect
how can I properly save it?
thanks!
UPDATE: the code I'm using is:
BitmapSource bitmap = preview.Source as BitmapImage;
Rectangle r = new Rectangle();
r.Fill = new ImageBrush(bitmap);
r.Effect = effect;
Size sz = new Size(bitmap.PixelWidth, bitmap.PixelHeight);
r.Measure(sz);
r.Arrange(new Rect(sz));
var rtb = new RenderTargetBitmap(bitmap.PixelWidth, bitmap.PixelHeight, bitmap.DpiX, bitmap.DpiY, PixelFormats.Pbgra32);
rtb.Render(r);
PngBitmapEncoder png = new PngBitmapEncoder();
png.Frames.Add(BitmapFrame.Create(rtb));
Stream stm = File.Create("new.png");
png.Save(stm);
stm.Close();