我打印带有图像的 XPS 文档,其中包含 QR 码。在此处创建图像示例:
Image image = CreatePresentation(qrCode);
image.Height = 200;
image.Width = 200;
image.HorizontalAlignment = HorizontalAlignment.Center;
image.VerticalAlignment = VerticalAlignment.Center;
image.Stretch = Stretch.None;
在哪里
public static Image CreatePresentation(System.Drawing.Image source)
{
Stream stream = new MemoryStream();
source.Save(stream, ImageFormat.Png);
Image image = new Image();
BitmapImage src = new BitmapImage();
src.BeginInit();
src.StreamSource = stream;
src.EndInit();
image.Source = src;
return image;
}
当我有监视器 dpi=96 时,打印页面上的图像尺寸(打印后在纸上)比我有 montor dpi=120 时更大。如何在不同 dpi 上打印相同尺寸的图像?