类似的这种代码有问题,频繁的增加,不消除就会占用资源。
你项目有两处要改。
Dim p As WinForm.Painter =e.Form.CreateControl("p", ControlTypeEnum.Painter)
p.Width = zwidth '原始照片宽动态赋给画板宽
p.Height = zheight '原始照片高动态赋给画板高
Dim g As Graphics = p.Graphics
g.Clear(Color.White)
g.DrawImage(getImage(route),0,0,zwidth,zheight)
g.DrawImage(bar.GetImage,(zwidth-200),(zheight-680),150,150)
Dim rm As New prt.RenderImage '定义一个图片对象
rm.Image = GetImage("archives.ico") '设置图片
rm.Style.ImageAlign.StretchHorz = True '水平拉伸
g.DrawImage(rm.Image,(zwidth-75),(zheight-85),30,30)
Dim fnt As New Font("黑体",20,FontStyle.Bold) '黑体,10号,加粗
g.DrawString(fn,fnt,Brushes.Aqua,(zwidth-250),(zheight-35))
p.Repaint()
Dim img As Image = p.Image
p.Save(route2)
img.save(route2)
改成
Dim p As WinForm.Painter =e.Form.CreateControl("p", ControlTypeEnum.Painter)
For Each r As DataRow In DataTables("newtrj").Select("id>1") '从数据表中提取数据
bar.Code = r("qrcord")
Dim fn As String = ""
fn = r("cn_name")
If fn <> "" And filesys.FileExists("d:\as\" & fn & ".jpg") = True Then
Dim route As String = "d:\as\" & fn & ".jpg" '原始照片存放路径
Dim route2 As String ="d:\qrcord\" & fn & ".jpg"
Dim zwidth = getImage(route).width '原始照片宽
Dim zheight = getImage(route).height '原始照片高
p.Width = zwidth '原始照片宽动态赋给画板宽
p.Height = zheight '原始照片高动态赋给画板高
Dim g As Graphics = p.Graphics
g.Clear(Color.White)
g.DrawImage(getImage(route),0,0,zwidth,zheight)
g.DrawImage(bar.GetImage,(zwidth-200),(zheight-680),150,150)
Dim rm As New prt.RenderImage '定义一个图片对象
rm.Image = GetImage("archives.ico") '设置图片
rm.Style.ImageAlign.StretchHorz = True '水平拉伸
g.DrawImage(rm.Image,(zwidth-75),(zheight-85),30,30)
Dim fnt As New Font("黑体",20,FontStyle.Bold) '黑体,10号,加粗
g.DrawString(fn,fnt,Brushes.Aqua,(zwidth-250),(zheight-35))
p.Repaint()
Dim img As Image = p.Image
p.Save(route2)
img.save(route2)
End If
Next
e.Form.RemoveControl("p")