首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何将BitmapSource旋转任意角度?

如何将BitmapSource旋转任意角度?
EN

Stack Overflow用户
提问于 2012-02-17 09:55:46
回答 1查看 3.3K关注 0票数 3

我如何创建一个BitmapSource d,它是BitmapSource s的内容旋转了任意角度a?RotateTransform是不合适的,因为它仅限于90度倍数的角度。

编辑: RotateTransform限制的演示:

代码语言:javascript
运行
复制
        // Create the TransformedBitmap to use as the Image source.
        TransformedBitmap tb = new TransformedBitmap();
        // Create the source to use as the tb source.
        BitmapImage bi = (BitmapImage)capture;
        // Properties must be set between BeginInit and EndInit calls.
        tb.BeginInit();
        tb.Source = bi;
        // Set image rotation.
            var transform = new System.Windows.Media.RotateTransform(angle:30);
        tb.Transform = transform;
        tb.EndInit();  // "Transform must be a combination of scales, flips, and 90 degree rotations"
EN

回答 1

Stack Overflow用户

发布于 2012-02-17 12:12:08

我在Blend中创建了一个测试项目。RotateTransform可以是任何角度:

代码语言:javascript
运行
复制
<Grid x:Name="LayoutRoot" DataContext="{Binding Source={StaticResource SampleDataSource}}">
    <Image Margin="0,0,191,122" Source="{Binding Property1}" RenderTransformOrigin="0.5,0.5">
        <Image.RenderTransform>
            <TransformGroup>
                <ScaleTransform/>
                <SkewTransform/>
                <RotateTransform Angle="26.565"/>
                <TranslateTransform/>
            </TransformGroup>
        </Image.RenderTransform>
    </Image>
</Grid>

我创建了SampleDataSource,其中Property1是一个图像。

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

https://stackoverflow.com/questions/9321889

复制
相关文章

相似问题

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