I am trying to write a program to print an image (jpg file) dirrectly to the default printer. Here is the code.
Imports System.Drawing
Imports System.Drawing.Printing
Module Module1
Sub Main()
Dim printer As PrintDocument = New PrintDocument
AddHandler printer.PrintPage, AddressOf PrintImage
printer.Print()
End Sub
Private Sub PrintImage(ByVal sender As Object, ByVal e As PrintPageEventArgs)
Dim img As Image = Image.FromFile("C:\...\MyImage.jpg")
e.Graphics.DrawImage(img, 0, 0)
End Sub
End Module
However, when I have a big image, resolution is very high (4000 x 6000 pixels). I would like to resize the image first before I print. Is there a way to resize the image? Could some one help me? Thanks
Aaron MezaPosted Dec 12, 2008, 12:45 AM
Function ThumbnailCallback() AS Boolean
Private Sub PrintImage(ByVal sender As Object, ByVal e As PrintPageEventArgs)Return False
End Function
Dim objCallback AS System.Drawing.Image.GetThumbnailImageAbort = new System.Drawing.Image.GetThumbnailImageAbort(AddressOf ThumbnailCallback)
Dim img As Image = Image.FromFile("C:\...\MyImage.jpg")
e.Graphics.DrawImage(img, 0, 0)
End Sub