I'm trying to print an image (QR code) from Silverlight 4 app, however the image is antialised when printed (I have tried both XPS file printer and hardware printer)image is blury, and is not readable by barcode reader.
Image from printed XPS document http://img805.imageshack.us/img805/7677/qraliasing.png
I'm using this simple code to print it:
WriteableBitmap bitmap = new WriteableBitmap(width, height);
//write bitmap pixels
Image image = new Image(){Stretch = Stretch.None};
image.Source = bitmap;
image.Width = bitmap.PixelWidth;
image.Height = bitmap.PixelHeight;
//Print
PrintDocument printDocument = new PrintDocument();
printDocument.PrintPage += (sender, args) =>
{
args.PageVisual = image;
};
printDocument.Print("QrCode");
I have found a solution.
When printing Image control in Silverlight 4, it sends to printer not a "print screen" of an image control like it looks in your UserControl but an image set in it's source property. If you generate two bitmaps of 100x100 px and 1000x1000px resolutions and put them in 100x100px size Image controls the print result will not be the same as you may expect.
So the solution is to generate high resolution image (or upscale image) and put it in Image controls of desired size.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With