在位图源中旋转图像 [英] Rotating an Image in a BitmapSource

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

问题描述

我有一个图像在BitmapSource中传递,它可能是Black& Black等几种像素类型之一.白色,灰度或RGB.我想将此图像旋转一个任意角度(例如17度),然后将其保存到磁盘.我正在尝试使用WPF /C#(起初我以为我会使用TransformedBitmap,但发现该角度不合适,因为角度只能是90的倍数),但是我不确定该如何进行.我可以看到如何通过应用RotateTransform对XAML中的图像/控件轻松完成此操作 但我不确定如何在实例中使用它(以及如何保留像素类型).

I've got an image being passed in a BitmapSource it could be one of several pixel types such as Black & White, Greyscale or RGB. I want to rotate this image by an arbitary angle (say 17 degrees) and then save it to disk. I'm trying to to this with WPF / C# (Initially I thought I'd use TransformedBitmap but found out this was unsuitable as the angle can only be a multiple of 90) but I'm not sure how to progress. I can see how this can easily be done to images/controls in XAML by appling a RotateTransform but I'm not sure how to use this in my instance (and also how to preserve the pixel type).

谢谢

干杯,迈克

推荐答案

通过应用RotateTransform,我可以看到如何轻松地对XAML中的图像/控件执行此操作,但是我不确定如何在实例中使用它(以及如何保留像素类型).

I can see how this can easily be done to images/controls in XAML by appling a RotateTransform but I'm not sure how to use this in my instance (and also how to preserve the pixel type).

谢谢


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

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