0

I have a question and i hope somebody can help me.

Im using the ZXing.Net plugin to generate a barcode from a number. All is working well and i get a barcode in a picture box. Now i would like to print this barcode but the image is all fuzzy. I've been trying to get it more sharp this is my code now:

 Private Sub PrintDocument_BO_PrintPage(sender As Object, e As Printing.PrintPageEventArgs) Handles PrintDocument_BO.PrintPage

        Dim myBitmap1 As Bitmap = New Bitmap(PrintBackorder.picBarcode.Width, PrintBackorder.picBarcode.Height)
        PrintBackorder.picBarcode.DrawToBitmap(myBitmap1, New Rectangle(0, 0, PrintBackorder.picBarcode.Width, PrintBackorder.picBarcode.Height))
        e.Graphics.InterpolationMode = Drawing.Drawing2D.InterpolationMode.HighQualityBicubic
        e.Graphics.PixelOffsetMode = PixelOffsetMode.HighQuality
        e.Graphics.SmoothingMode = Drawing.Drawing2D.SmoothingMode.HighQuality
        e.Graphics.CompositingQuality = Drawing.Drawing2D.CompositingQuality.HighQuality
        e.Graphics.DrawImage(myBitmap1, 625, 50)
 End sub

Is there something i could add or am i doing something wrong? Thank you!

Desz
  • 31
  • 7
  • 2
    How did you *get a barcode in a picture box*? Did you set the `Image` property? What is its SizeMode? What is the size of this BarCode? Or are you painting it? -- Remove `SmoothingMode` and try `InterpolationMode = InterpolationMode.NearestNeighbor`. – Jimi Aug 07 '21 at 12:59
  • Thank you Jimi, InterpolationMode = InterpolationMode.NearestNeighbor did the trick! – Desz Aug 07 '21 at 13:45

0 Answers0