开发者

Dot Net Vc++ undo drawline

In my application i am 开发者_运维问答drawing a line on a picturebox Image. I wish to undo or erase the last drawn line. How can we do that?

I was able to undo the last drawn line using a dictionary collection and then drawing the lines I require.

My issue now is when I first load the application, I want the lines to be drawn. I can do that using the PictureBox_Paint event, But in this event the lines are drawn only when the Graphics is created by e->Graphics, if I use pictureBox->CreateGraphcics() to draw the line, the lines are not drawn. Why is the e->graphics and picturebOx->CraeteGraphics() different? Which other function can I capture to draw lines at form load?


How are you drawing the line? GDI is an immediate-mode API, there's no undo. You'll either need to store the bitmap prior to the line in memory or on the disk so you can re-instate it, or you need to write your own drawing API (based on GDI if you will) so you can redo all the drawing steps until the line, or you can use a GDI pen mode that inverts the pixel colour. Then if you draw the same line again it will effectively undo the change. This however is not possible in GDI+ (as used in winforms) and it doesn't allow for anti-aliasing either.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜