[UWP]如何在UWP中旋转图像

编程入门 行业动态 更新时间:2024-10-15 12:36:59
本文介绍了[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 ! :)

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

You also have the same thread in this link :stackoverflow/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上关注我: twitter/NordineMhoumadi

更多推荐

[UWP]如何在UWP中旋转图像

本文发布于:2023-11-04 18:17:27,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1558667.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:图像   如何在   UWP

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!