c# - Resizing Image From Graphics? -


i'm trying resize image after copying screen, , can't figure out how it. tutorials i've been reading recommend using graphics.drawimage resize image, when run code, doesn't resize.

bitmap b = new bitmap(control.width, control.height); graphics g = graphics.fromimage(b); g.copyfromscreen(control.parent.rectangletoscreen(control.bounds).x, control.parent.rectangletoscreen(control.bounds).y, 0, 0, new size(control.bounds.width, control.bounds.height), copypixeloperation.sourcecopy);  g.drawimage(b, 0,0,newwidth, newheight); 

any appreciated, thanks!

try this. graphics won't "replace" image when use drawimage - draws input image on source, same the image you're trying draw it.

probably more concise way but.....

bitmap b = new bitmap(control.width, control.height); using (graphics g = graphics.fromimage(b)) {    g.copyfromscreen(control.parent.rectangletoscreen(control.bounds).x,        control.parent.rectangletoscreen(control.bounds).y, 0, 0,        new size(control.bounds.width, control.bounds.height),       copypixeloperation.sourcecopy); } bitmap output = new bitmap(newwidth, newheight); using (graphics g = graphics.fromimage(output)) {   g.drawimage(b, 0,0,newwidth, newheight); } 

Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -