Quantcast
Channel: I HATE WRITEABLEBITMAP
Viewing all articles
Browse latest Browse all 14

I HATE WRITEABLEBITMAP

$
0
0

The problem is that the attempt to force off-screen rendering of the Image objects didn't work. You'll see the difference if you render them on-screen by adding this to the end of MainPage_Loaded:

        TitlePanel.Children.Add(_objBlue)
        TitlePanel.Children.Add(_objOrange)
        TitlePanel.Children.Add(_objFucsia)

Something caused Silverlight to render them between the first and second calls to CreateScreenShotRecord, so they didn't appear the first time but appeared the second time.

Here's a workaround. Create your objects in the page constructor and add them to the page to make them render. In the page loaded event, remove the objects from the page. They will disappear before the screen is refreshed and won't actually become visible.

    Public Sub New()

        Me.DataContext = App.ViewModel

        InitializeComponent()

        _objBlue = New Image
        _objBlue.Source = New BitmapImage(New Uri("Images\blue.jpg", UriKind.Relative))
        _objBlue.Height = 5
        _objBlue.Width = 5
        _objBlue.Measure(New Size(5, 5))                    '//only for test
        _objBlue.Arrange(New Rect(0, 0, 5, 5))              '//only for test
        _objBlue.Visibility = Windows.Visibility.Visible    '//only for test

        _objOrange = New Image
        _objOrange.Source = New BitmapImage(New Uri("Images\orange.jpg", UriKind.Relative))
        _objOrange.Height = 5
        _objOrange.Width = 5
        _objOrange.Measure(New Size(5, 5))                  '//only for test
        _objOrange.Arrange(New Rect(0, 0, 5, 5))            '//only for test
        _objOrange.Visibility = Windows.Visibility.Visible  '//only for test

        _objFucsia = New Image
        _objFucsia.Source = New BitmapImage(New Uri("Images\fucsia.jpg", UriKind.Relative))
        _objFucsia.Height = 5
        _objFucsia.Width = 5
        _objFucsia.Measure(New Size(5, 5))                  '//only for test
        _objFucsia.Arrange(New Rect(0, 0, 5, 5))            '//only for test
        _objFucsia.Visibility = Windows.Visibility.Visible  '//only for test

        TitlePanel.Children.Add(_objBlue)
        TitlePanel.Children.Add(_objOrange)
        TitlePanel.Children.Add(_objFucsia)
    End Sub

    Private Sub MainPage_Loaded(sender As Object, e As System.Windows.RoutedEventArgs) Handles MyBase.Loaded
        TitlePanel.Children.Remove(_objBlue)
        TitlePanel.Children.Remove(_objOrange)
        TitlePanel.Children.Remove(_objFucsia)
    End Sub


Richard Woo

Viewing all articles
Browse latest Browse all 14

Trending Articles