How to: Rotate Images with the .NET Framework

 

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

For the latest documentation on Visual Studio 2017, see How to: Rotate Images with the .NET Framework on docs.microsoft.com.

The following code example demonstrates the use of the System.Drawing.Image class to load an image from disk, rotate it 90 degrees, and save it as a new .jpg file.

System_CAPS_ICON_note.jpg Note

GDI+ is included with Windows XP and is available as a redistributable for Windows NT 4.0 SP 6, Windows 2000, Windows 98, and Windows Millennium Edition. To download the latest redistributable, see http://go.microsoft.com/fwlink/?linkid=11232.

#using <system.drawing.dll>  
  
using namespace System;  
using namespace System::Drawing;  
  
int main()  
{  
   Image^ image = Image::FromFile("SampleImage.jpg");  
   image->RotateFlip( RotateFlipType::Rotate90FlipNone );  
   image->Save("SampleImage_rotated.jpg");  
   return 0;  
}  

.NET Programming with C++/CLI (Visual C++)

Show: