c# - paint program not saving edited picture -
am developing paint application in c# , vs2010
the start-up interface blank picturebox
, did mousedown
, mousemove
event handler brush tool paint , works fine
when try save new picture (after painting on blank picturebox) enter file , , it's blank picture.
the problem code not saving effects.
why?
mousedown event handler
private void mousedown(object sender, mouseeventargs e) { if (currentfunction == "drawfree") { if (e.button == mousebuttons.left) releaseflag = true; startpoint = e.location; } }
mousemove event handler
private void mousemove(object sender, mouseeventargs e) { if (currentfunction == "drawfree") { if (releaseflag) { endpoint = e.location; g = picturebox1.creategraphics(); g.drawline(p, startpoint, endpoint); } startpoint = endpoint; } }
save code
private void savephototoolstripmenuitem_click(object sender, eventargs e) { using (bitmap bmp = new bitmap(picturebox1.clientsize.width, picturebox1.clientsize.height)) { using (graphics g = graphics.fromimage(bmp)) { image yourimage = picturebox1.image; bitmap yourbitmap = new bitmap(yourimage); g.drawimage(yourbitmap, new rectangle(0, 0, bmp.width, bmp.height), new rectangle(0, 0, yourimage.width, yourimage.height), graphicsunit.pixel); } bmp.save(@"d:\yourfile.png", imageformat.png); } }
since bitmapped "yourbitmap" yourimage, try replacing bmp.save yourbitmap.save
yourbitmap.image.save(@"d:\yourfile.png", imageformat.png);
Comments
Post a Comment