c# - rotating an image modifies the resolution and clarity -


consider code below rotate image.

the problem resolution of image getting low , image getting unclear.

how can avoid problem?

private bitmap rotateimage(bitmap b, float angle) {     //create new empty bitmap hold rotated image     bitmap returnbitmap = new bitmap(b.width, b.height);     //make graphics object empty bitmap     graphics g = graphics.fromimage(returnbitmap);     //move rotation point center of image     g.translatetransform((float)this.width / 2, (float)this.height / 2);     g.interpolationmode = system.drawing.drawing2d.interpolationmode.highqualitybilinear;     //rotate     g.rotatetransform(angle);     g.interpolationmode = system.drawing.drawing2d.interpolationmode.highqualitybilinear;     g.translatetransform(-(float)this.width / 2, -(float)this.height / 2);     g.interpolationmode = system.drawing.drawing2d.interpolationmode.highqualitybilinear;     //draw passed in image onto graphics object     g.drawimage(b, new point(0, 0));     g.dispose();     return returnbitmap; } 

repeated rotations cause quality drop repeated interpolations take toll on image. best way avoid rotate source image once. if you're building system in image gets rotated multiple times rotate source image total rotation amount instead of applying small delta rotations rotated image each time.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -