[UWP]如何在UWP中旋转图像 [英] [UWP]How to rotate image in UWP

查看:81
本文介绍了[UWP]如何在UWP中旋转图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello All, 

Hello All, 

我从相机中捕获图像,并使用位图编码器和解码器压缩图像,然后将其存储在存储文件中。

I captured image from my camera and used bitmap encoder and decoder to compress image and then storing it in Storage File.

之后我将图像设置为我的< Image>控制,但图像始终以90度顺时针旋转显示。 

After that i set the image to my <Image> control , however the image is displayed in rotated clockwise 90 degree always. 

我希望图像以原始形式显示,并在其中捕获图像。

I want the image to be display in original form in which it was captured.

因此,任何人都可以建议我需要设置哪个属性或需要使用哪个控件,以便可以正确显示该图像。

So can anyone suggest which property i need to set or which control i need to use, So that image can be display properly.

谢谢, 

S.Bhatt

Subrahamanya Bhatt

Subrahamanya Bhatt

推荐答案

嗨!

您可以使用此代码旋转图片: 

You can use this code for rotate the image : 

XAML: 

<Image Stretch="Uniform" Name="Display" Source="Assets/WATPSD.png">  
    <Image.Projection>  
        <PlaneProjection/>  
    </Image.Projection>  
</Image>

C#

private Storyboard rotation = new Storyboard();  
public MainPage()   
{  
    this.InitializeComponent();  
    DoubleAnimation animation = newDoubleAnimation();  
    animation.From = 0.0;  
    animation.To = 360.0;  
    animation.BeginTime = TimeSpan.FromSeconds(1);  
    animation.RepeatBehavior = RepeatBehavior.Forever;  
    Storyboard.SetTarget(animation, Display);  
    Storyboard.SetTargetProperty(animation, "(UIElement.Projection).(PlaneProjection.Rotation" + "Y" + ")");  
    rotation.Children.Clear();  
    rotation.Children.Add(animation);  
    rotation.Begin();  
  
}  

您可以在此行中将值设置为直角: 

You'll put the value to right angle in this line : 

animation.To = 360.0;

不要忘记停止动画! :)

Don't forget to stop the the animation ! :)

此链接中也有相同的主题:  https://stackoverflow.com/questions/42057997/uwp-c-sharp-rotating-bmp

You also have the same thread in this link : https://stackoverflow.com/questions/42057997/uwp-c-sharp-rotating-bmp


希望它有用。

Hope it wil be useful.



记得将答案标记为答案,如果他们有帮助,这将帮助正在寻找相同或类似问题解决方案的其他人
。 

Please remember to mark the replies as answers if they help, this will help others who are looking for solutions to the same or similar problem


在Twitter上关注我:  https://twitter.com/NordineMhoumadi


这篇关于[UWP]如何在UWP中旋转图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆