Skip to content

Instantly share code, notes, and snippets.

@papeMK2
Last active August 29, 2015 14:00
Show Gist options
  • Save papeMK2/11390951 to your computer and use it in GitHub Desktop.
Save papeMK2/11390951 to your computer and use it in GitHub Desktop.
LotateImage
private static byte[] LotateImage(byte[] image)
{
var converter = new ImageConverter();
var img = (Image)converter.ConvertFrom(image);
var bmp = new Bitmap(img);
var props = bmp.PropertyItems;
for (int i = 0; i < props.Length; i++)
{
var p = props[i];
if (p.Id == 0x0112)
{
switch (p.Value[0])
{
case 1:
break;
case 3:
bmp.RotateFlip(System.Drawing.RotateFlipType.Rotate180FlipNone);
break;
case 6:
bmp.RotateFlip(System.Drawing.RotateFlipType.Rotate270FlipNone);
break;
case 8:
bmp.RotateFlip(System.Drawing.RotateFlipType.Rotate90FlipNone);
break;
}
}
}
var ms = new MemoryStream();
bmp.Save(ms,System.Drawing.Imaging.ImageFormat.Jpeg);
return ms.GetBuffer();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment