it looks like WriteableBitmap for Silverlight for Windows Phone has a really annoying bug. I have the following code and xaml:
public partial class MainPage : PhoneApplicationPage { CompositeTransform rotate = new CompositeTransform(); public MainPage() { InitializeComponent(); } private void Button_Click(object sender, System.Windows.RoutedEventArgs e) { this.rotate.Rotation += 15; WriteableBitmap bmp = new WriteableBitmap(this.button, rotate); this.image.Source = bmp; Dispatcher.BeginInvoke(() => Debug.WriteLine("{0}, {1}", bmp.PixelWidth, bmp.PixelHeight)); } }
Here is the haml:
<Grid> <Button VerticalAlignment="Top" HorizontalAlignment="Center" Content="This is a textblock inside a layout" x:Name="button"/> <Image VerticalAlignment="Center" HorizontalAlignment="Center" x:Name="image"/> <Button VerticalAlignment="Bottom" Content="Rotate" Click="Button_Click"/> </Grid>
When you press the bottom button, the top button is rendered using a recordable bitmap using a compound transform. After each rendering, the resulting image of the top button is larger than the previous one. In addition, the values ββof the PixelWith and PixelHeight property for the recorded bitmap are very different from the RenderSize of the Image object. Does anyone know what is going on?
source share