我如何创建一个BitmapSource d,它是BitmapSource s的内容旋转了任意角度a?RotateTransform是不合适的,因为它仅限于90度倍数的角度。
编辑: RotateTransform限制的演示:
// 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"发布于 2012-02-17 12:12:08
我在Blend中创建了一个测试项目。RotateTransform可以是任何角度:
<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是一个图像。
https://stackoverflow.com/questions/9321889
复制相似问题