I have a grid (wpf) and want to save the grid as an image. The grid name is gridPrintPanel (WxH: 1800x1200). I tried to use RenderTargetBitmap to get data and save as a file:
string tempFile = @"D:\temp.png";
RenderTargetBitmap renderTargetBitmap = new RenderTargetBitmap(1800, 1200, 0, 0, PixelFormats.Pbgra32);
renderTargetBitmap.Render(ViewInstance.gridPrintPanel);
PngBitmapEncoder pngImage = new PngBitmapEncoder();
pngImage.Frames.Add(BitmapFrame.Create(renderTargetBitmap));
using (Stream fileStream = File.Create(tempFile))
{
pngImage.Save(fileStream);
}
The problem is: the result image is different when I run the program on 2 different machine with different screen resolution. The machine with full HD screen give me expected result however another machine with screen resolution 1024x768 give an image with less data. My grid contains a datagrid and the second machine give me a datagrid which lost some last rows. The question I want to ask here: Is the resolution of a screen could affect the result ? And how could I do to get the same result i.e the full image on both machine.