locked
Change image Orientation RRS feed

  • Question

  • User-1877113880 posted

    I have the below code which is working as i expected (I think)

    Can someone tell me how or what I'm suppose to return back, I understand its a byte of the image, but how do you get the new image after the orientation has been changed?

     public byte[] ChangeImageOreintation(byte[] images)
            {
                var ms = new MemoryStream(images);
                var originalImage = Image.FromStream(ms);
    
                if (originalImage.PropertyIdList.Contains(0x0112))
                {
                    int rotationValue = originalImage.GetPropertyItem(0x0112).Value[0];
                    switch (rotationValue)
                    {
                        case 1: // landscape, do nothing
                            break;
    
                        case 8: // rotated 90 right
                            // de-rotate:
                            originalImage.RotateFlip(rotateFlipType: RotateFlipType.Rotate270FlipNone);
                            break;
    
                        case 3: // bottoms up
                            originalImage.RotateFlip(rotateFlipType: RotateFlipType.Rotate180FlipNone);
                            break;
    
                        case 6: // rotated 90 left
                            originalImage.RotateFlip(rotateFlipType: RotateFlipType.Rotate90FlipNone);
                            break;
                    }
                }
    
                return images;
            }

    Saturday, December 20, 2014 3:20 AM

All replies