JpegBitmapEncoder.Rotation Property

Definition

Gets or sets a value that represents the degree to which a Joint Photographics Experts Group (JPEG) image is rotated.

C#
public System.Windows.Media.Imaging.Rotation Rotation { get; set; }

Property Value

The degree to which the image is rotated.

Examples

The following example demonstrates how to set the value of the Rotation property.

C#
BitmapSource image = BitmapSource.Create(
    width,
    height,
    96,
    96,
    PixelFormats.Indexed1,
    myPalette,
    pixels,
    stride);
C#
FileStream stream = new FileStream("new.jpg", FileMode.Create);
JpegBitmapEncoder encoder = new JpegBitmapEncoder();
TextBlock myTextBlock = new TextBlock();
myTextBlock.Text = "Codec Author is: " + encoder.CodecInfo.Author.ToString();
encoder.FlipHorizontal = true;
encoder.FlipVertical = false;
encoder.QualityLevel = 30;
encoder.Rotation = Rotation.Rotate90;
encoder.Frames.Add(BitmapFrame.Create(image));
encoder.Save(stream);

Remarks

Rotation is supported only in 90-degree increments.

The rotation represents a lossless transformation of the source image and replaces any previous lossless transformation.

Applies to

Product Versions
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10