Last active
August 29, 2015 14:00
-
-
Save papeMK2/11390951 to your computer and use it in GitHub Desktop.
LotateImage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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