sainavya1215
asked on
Print an Image in a picturebox control
hi,
Below code prints image on a vb.net picturebox control. if there is a large image it fits it exactly inside the picturebox control. But the print lies during printing instead of printing the image size on the picturebox control it prints actual image size.
How could we print the image as per the size of picturebox?
here is the code used:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
PictureBox1.SizeMode = PictureBoxSizeMode.Stretch Image
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim pd As New System.Drawing.Printing.Pr intDocumen t
AddHandler pd.PrintPage, AddressOf OnPrintPage
pd.Print()
End Sub
Private Sub OnPrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.Pr intPageEve ntArgs)
e.Graphics.DrawImage(Pictu reBox1.Ima ge, 0, 0)
End Sub
Below code prints image on a vb.net picturebox control. if there is a large image it fits it exactly inside the picturebox control. But the print lies during printing instead of printing the image size on the picturebox control it prints actual image size.
How could we print the image as per the size of picturebox?
here is the code used:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
PictureBox1.SizeMode = PictureBoxSizeMode.Stretch
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim pd As New System.Drawing.Printing.Pr
AddHandler pd.PrintPage, AddressOf OnPrintPage
pd.Print()
End Sub
Private Sub OnPrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.Pr
e.Graphics.DrawImage(Pictu
End Sub
ASKER
Could u pls let me know what code has to be eliminated here and where exactly is ur code to be added.......
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim pd As New System.Drawing.Printing.Pr intDocumen t
AddHandler pd.PrintPage, AddressOf OnPrintPage
pd.Print()
End Sub
Private Sub OnPrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.Pr intPageEve ntArgs)
e.Graphics.DrawImage(Pictu reBox1.Ima ge, 0, 0)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim pd As New System.Drawing.Printing.Pr
AddHandler pd.PrintPage, AddressOf OnPrintPage
pd.Print()
End Sub
Private Sub OnPrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.Pr
e.Graphics.DrawImage(Pictu
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for that........
you're welcome :)
Dim result As System.Drawing.Image
result = PictureBox1.Image.GetThumb
Then you can use "result" instead "PictureBox1.Image"