public static Bitmap AutoDeskew(this Image In) { Bitmap bitmap = new Bitmap(In); ImgRectify imgRectify = new ImgRectify(bitmap); double skewAngle = imgRectify.GetSkewAngle(); Bitmap bitmap2 = ImageHelper.Rotate(bitmap, (int)skewAngle); Bitmap image = (Bitmap)bitmap2.Clone(); Graphics graphics = Graphics.FromImage(bitmap2); graphics.FillRectangle(ImageHelper.whitebrush, new Rectangle(0, 0, bitmap2.Width, bitmap2.Height)); graphics.DrawImage(image, new Point(0, 0)); return(bitmap2); }
public static Bitmap Rotate(this Image im, int angle) { return(ImageHelper.Rotate(new Bitmap(im), angle)); }