I've got a control that is essentially an Image with an AdornerDecorator layer on top which acts as a layer for mouse selection. What I'm trying to do is to get the section of the Image which has been selected without having to deal with mapping the co-ordinates of the selection back to the image (as there potentially many transforms which would make that complecated).
So far I'm using the following, but it only gets the visual for the selection border (so nothing) rather than the section of the image below it as well.
RenderTargetBitmap rtb = new RenderTargetBitmap(
Convert.ToInt32(this.ActualWidth),
Convert.ToInt32(this.ActualHeight),
96, 96,
PixelFormats.Pbgra32);
rtb.Render(inner);
PngBitmapEncoder png = new PngBitmapEncoder();
png.Frames.Add(BitmapFrame.Create(rtb));
using (Stream stream = File.Create(@"C:\Temp\testImg.png"))
{
png.Save(stream);
}
I fear that this approach might not be feasable, but I want to check just incase I'm missing something straight forward first.
Thanks!