Rotate or flip the current image.
Syntax

[C#]

virtual void RotateFlip(RotateFlipType type);

[Visual Basic]

Overidable Sub RotateFlip(type As RotateFlipType)
Params
Name Description
type The type of transformation to use.
Notes

None.

Example

[C#]RotateFlipType[] types = new RotateFlipType[] {
  RotateFlipType.RotateNoneFlipNone,
  RotateFlipType.Rotate90FlipNone,
  RotateFlipType.Rotate180FlipNone,
  RotateFlipType.Rotate270FlipNone,
  RotateFlipType.RotateNoneFlipX,
  RotateFlipType.Rotate90FlipX,
  RotateFlipType.Rotate180FlipX,
  RotateFlipType.Rotate270FlipX,
};
using (Image img = Bitmap.FromFile(Server.MapPath("rez/ming-jun-tan-o6ICDlt5_2k-unsplash.jpg"))) {
  const int gridSize = 3;
  const int imageSize = 200;
  const int imageBorder = 10;
  double aspectRatio = img.Width / (double)img.Height;
  int height = (int)Math.Round(imageSize / aspectRatio);
  using (Image small = img.GetThumbnailImage(imageSize, height)) {
    using (Bitmap bm = new Bitmap(imageSize * gridSize, imageSize * gridSize)) {
      using (Graphics graphics = Graphics.FromImage(bm)) {
        RectangleF rect = new RectangleF(0, 0, imageSize, imageSize);
        for (int i = 0; i < types.Length; i++) {
          RotateFlipType type = types[i];
          int x = i % gridSize, y = i / gridSize;
          PointF offset = new PointF(imageSize * x, imageSize * y);
          RectangleF rc = rect + offset;
          using (Bitmap copy = (Bitmap)small.Clone()) {
            copy.RotateFlip(type);
            rc.Inflate(-imageBorder, -imageBorder);
            rc = RectangleF.FitIn(rc, copy.Bounds, FitType.WidthAndHeight);
            graphics.DrawImage(copy, rc);
          }
        }
      }
      bm.Save(Server.MapPath("IG8_Image_RotateFlip.jpg"));
    }
  }
}


The code here creates a series of thumbnails, left to right and top to bottom. Each thumbnail is rotated or flipped a different way. The final output is shown below.


ming-jun-tan-o6ICDlt5_2k-unsplash.jpg


IG8_Image_RotateFlip.jpg