简体   繁体   中英

Printing XPS document with image. Different image size when set different dpi

I printing XPS document with images, that contains QR-codes. Image creating sample here:

 Image image = CreatePresentation(qrCode);
 image.Height = 200;
 image.Width = 200;
 image.HorizontalAlignment = HorizontalAlignment.Center;
 image.VerticalAlignment = VerticalAlignment.Center;
 image.Stretch = Stretch.None;

where

 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;
    }

When i have monitor dpi=96 then image size on printed page (on paper after printing) more larger than when i have montor dpi=120. How i can print images with the same size on different dpi?

When i replaced

 image.Stretch = Stretch.None;

on

 image.Stretch = Stretch.Fill;

image began print correct

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM