JpegBitmapEncoder.Rotation Property

 

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

Namespace:   System.Windows.Media.Imaging
Assembly:  PresentationCore (in PresentationCore.dll)

public Rotation Rotation { get; set; }

Property Value

Type: System.Windows.Media.Imaging.Rotation

The degree to which the image is rotated.

Rotation is supported only in 90-degree increments.

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

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

BitmapSource image = BitmapSource.Create(
    width,
    height,
    96,
    96,
    PixelFormats.Indexed1,
    myPalette,
    pixels,
    stride);
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);

.NET Framework
Available since 3.0
Return to top
Show: