首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >BitmapImage旋转

BitmapImage旋转
EN

Stack Overflow用户
提问于 2011-07-06 23:59:37
回答 2查看 2.7K关注 0票数 1

在我的ModelView中,我有一个BitmapImages的ObservableCollection,它显示在我的视图的列表框中。我正在尝试旋转ObservableCollection中选定的图像。

EN

回答 2

Stack Overflow用户

发布于 2011-07-07 22:03:58

好了,弄清楚了,如果有什么看起来很愚蠢的事情,你可以让我知道

代码语言:javascript
复制
//Create a transform
TransformedBitmap tBmp = new TransformedBitmap();
tBmp.BeginInit();

//Set the source = to the image currently selected
tBmp.Source = _Scans[_selectedImage].MyImage;
RotateTransform rt = new RotateTransform(180);
tBmp.Transform = rt;
tBmp.EndInit();

//Create a new source after the transform
BitmapSource s1 = tBmp;
BitmapImage bi = BitmapSourceToBitmapImage(s1);

//Add create the item and replace the current item in the collection
//edited according to comment
//ScannedImages s = new ScannedImages();
//s.MyImage = bi;
//_Scans[_selectedImage] = s;
Scans[_selectedImage].MyImage = BitmapSourceToBitmapImage(s1);
票数 1
EN

Stack Overflow用户

发布于 2011-07-07 00:40:34

在定义图像显示方式(作为ListBox项)的DateTemplate中,可以使用.RenderTransform属性来转换/旋转控件。

Button示例:

代码语言:javascript
复制
<Button
            <Button.RenderTransform>
                <RotateTransform CenterX="0" CenterY="0" Angle="45"/>
            </Button.RenderTransform>
            Test</Button>

Have a read more on How to Rotate an object? MSDN Article

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6599453

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档