我在我的解决方案中创建了一个绘图应用程序,通过这个code.by,我可以在picturebox中绘制图像并可以保存。当我单击cleared按钮时,picturebox上的图像将被清除,但问题是在清除图像后,如果不重新加载窗体,则无法在picturebox中绘制任何内容
dim mousepath as new system.drawing.drawing2d.graphicspath()
in pageload
picturebox1.image=new bitmap(picturebox1.clientsize.height,picturebox1.clientsize.width)
picturebox1_paint(...)
myusercolor=(sysytem.drawing.color.black)
myalpha=100
using g as graphics=graphics.fromimage(picturebox1.image)
g.clear(color.white)
dim currentpen as pen=new pen(color.fromargb(myalpha,myusercolor),mypenwidth) g.drawpath(currentpen,mousepath)
in mousedown
if e.button=mousebutton.left then
mousepath.startfigure()
end if
in mousemove
if e.button=mousebutton.left then
mousepath.addline(e.x,e.y,e.x,e.y)
end if
picturebox1.invalidate
clearbutton_click
picturebox1.image.dispose()
picturebox1.image=nothing问题:如果有人知道这个问题的解决方案,请帮助我。这对me.thank你很重要
发布于 2009-09-16 09:47:05
清除后,您将设置picturebox1.image=nothing,但随后您的Graphics对象将来自该图像。这就是为什么它不能工作的原因。您必须在清除时设置一个新的位图,如第一次:
picturebox1.image=new bitmap(picturebox1.clientsize.height,picturebox1.clientsize.width)
mousepath.Reset();https://stackoverflow.com/questions/1431992
复制相似问题