Last active
March 11, 2019 23:16
-
-
Save Spraynard/bd7d233d7b9205a6fedd8c85436e6d8e to your computer and use it in GitHub Desktop.
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
using System.Windows.Controls; | |
using System.Windows.Documents; | |
using System.Windows.Media; | |
... | |
FileInfo imgInfo = new FileInfo(path_to_img) | |
// Create rotate transform that will be applied to our image. | |
RotateTransform transform = new RotateTransform(90); // 90-degree rotation transform. | |
// Control type | |
Image myImage = new Image(); | |
BitmapImage bitmapImg = new BitmapImage(); | |
// Create a Transformed Bitmap | |
TransformedBitmap bitmapImgTransform = new TransformedBitmap(); | |
bitmapImg.BeginInit() | |
bitmap.UriSource = new Uri(imgInfo.FullName); | |
bitmap.EndInit(); | |
// Setting the properties of our transformed bitmap. | |
bitmapImgTransform.BeginInit(); | |
bitmapImgTransform.Source = bitmap; | |
bitmapImgTransform.Transform = transform; // Transform is applied through the | |
bitmapImgTransform.EndInit(); | |
myImage.Source = bitmapImgTransform; // Setting our image's source as the transformed bitmap. | |
// Create our BlockUIContainer | |
BlockUIContainer container = new BlockUIContainer(); | |
container.Child = myImage; | |
// Insert container with image into the document. | |
FlowDocument doc = new FlowDocument(); | |
doc.Blocks.Add(container); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment