www.pudn.com > OCR.zip > rotateImage.cs, change:2010-03-16,size:1356b


using System; 
using System.Drawing; 
 
/// <summary> 
/// Summary description for Class1 
/// </summary> 
///  
namespace OCR 
{ 
    public class rotateImage 
    { 
 
     
public  Image RotateImage(Image img, float rotationAngle) 
 
{ 
 
    //create an empty Bitmap image 
 
    Bitmap bmp = new Bitmap(img.Width, img.Height); 
 
  
 
    //turn the Bitmap into a Graphics object 
 
    Graphics gfx = Graphics.FromImage(bmp); 
 
  
 
    //now we set the rotation point to the center of our image 
 
    gfx.TranslateTransform((float)bmp.Width / 2, (float)bmp.Height / 2); 
 
  
 
    //now rotate the image 
 
    gfx.RotateTransform(rotationAngle); 
 
  
 
    gfx.TranslateTransform(-(float)bmp.Width / 2, -(float)bmp.Height / 2); 
 
 
 
    //set the InterpolationMode to HighQualityBicubic so to ensure a high 
 
    //quality image once it is transformed to the specified size 
 
 
    gfx.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic; 
  
 
    //now draw our new image onto the graphics object 
 
    gfx.DrawImage(img, new Point(0, 0)); 
 
  
 
    //dispose of our Graphics object 
 
    gfx.Dispose(); 
 
  
 
    //return the image 
 
    return bmp; 
 
}  
 
        public rotateImage() 
        { 
            // 
            // TODO: Add constructor logic here 
            // 
        } 
    } 
}