i'm trying to print a bitmap.
i've put the printing code in a background worker on another thread.
this is the code i'm using.
Private Sub bw4print_DoWork(ByVal sender As System.Object, ByVal e As
System.ComponentModel.DoWorkEventArgs) Handles bw4print.DoWork
Dim MyDoc As New PrintDocument()
AddHandler MyDoc.PrintPage, AddressOf MyDoc_PrintPage
MyDoc.DefaultPageSettings.Landscape = True
MyDoc.Print()
My.Application.DoEvents()
End Sub
Private Sub MyDoc_PrintPage(ByVal sender As Object, ByVal e As
PrintPageEventArgs)
printGraph(e.Graphics, CSng((e.PageBounds.Width - 840) / 6),
CSng((e.PageBounds.Height - 519) / 3))
My.Application.DoEvents()
End Sub
Public Sub printGraph(ByVal gr As Graphics, ByVal x As Single, ByVal y
As Single)
If graph1.InvokeRequired Then
graph1.Invoke(New printGraphCallback(AddressOf printGraph), gr,
x, y)
Else
Dim g As Graphics = Graphics.FromImage(graph1.Image)
g.FillRectangle(Brushes.White, 770, 495, 70, 24)
gr.DrawImage(graph1.Image, x, y)
My.Application.DoEvents()
Dim bm As New Bitmap(My.Application.Info.DirectoryPath &
"\print.bmp")
g.DrawImage(bm, 765, 499)
My.Application.DoEvents()
End If
End Sub
i've got a 3ghz processor with 4gb of ram
the bitmap is only 25kb but the printing still ties up the system.
is there another way of doing this that leaves the system free for other
things while its printing?