tags:

views:

21

answers:

0

I have a rotate function that I rotate the image from a button. When I hit the rotate button again I cant because I am returning a transformedBitmap

here is my function Public Function RotateImage90(ByVal OrigImage As BitmapImage) As TransformedBitmap ' Create Image element. Dim rotated90 As New Image() rotated90.Width = 150

        ' Create the source to use as the tb source.
        'Dim bi As New BitmapImage()
        'bi.BeginInit()
        'bi.UriSource = New Uri(ImagePath, UriKind.RelativeOrAbsolute)
        'bi.EndInit()

        ' Create the TransformedBitmap to use as the Image source.
        Dim tb As New TransformedBitmap()

        ' Properties must be set between BeginInit and EndInit calls.
        tb.BeginInit()
        tb.Source = OrigImage
        ' Set image rotation.
        Dim transform As New RotateTransform(90)
        tb.Transform = transform
        tb.EndInit()
        ' Set the Image source.
        'rotated90.Source = tb

        Return tb 'rotated90

    End Function

Here is my button click

Private Sub RotateButton_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles RotateButton.Click
    Dim RotateImage As New Transformations.Rotate
    Dim RotatedImage As New TransformedBitmap

    Dim OrigImage As New BitmapImage
    OrigImage = CType(ImgOriginal.Source, BitmapImage)



    RotatedImage = RotateImage.RotateImage90(OrigImage)

    'Dim bmImageOrig As New BitmapImage()
    'bmImageOrig.BeginInit()
    'bmImageOrig.UriSource = New Uri(FileName, UriKind.Absolute)
    'bmImageOrig.EndInit()



    ImgOriginal.Source = RotatedImage
End Sub

I is there a way to return a bitmapImage of the transformedbitmap. Thanks! spafa9