Andrew Morton said:
Thanks but it is a bit much to have to run IIS. I doubt that anyone I give
my app to will be running that software. I just found the following for
anyone with the same problem:
First you create a new class derived from IValueConverter:
Public Class CustomImageConverter
Implements IValueConverter
'''<summary>
''' Converts System.Drawing.Bitmap to BitmapSource
'''</summary>
Public Function Convert(ByVal value As Object, ByVal targetType As Type,
ByVal parameter As Object, ByVal culture As
System.Globalization.CultureInfo) As Object Implements
IValueConverter.Convert
'No conversion to be done if value is null
If value Is Nothing Then
Return Nothing
End If
'Validate object being converted
If TypeOf value Is System.Drawing.Bitmap Then
'Use existing Interop functionality to perform conversion
Dim HBitmap As IntPtr = DirectCast(value,
System.Drawing.Bitmap).GetHbitmap()
Dim sizeOptions As System.Windows.Media.Imaging.BitmapSizeOptions =
System.Windows.Media.Imaging.BitmapSizeOptions.FromEmptyOptions()
Return
System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(HBitmap,
IntPtr.Zero, Int32Rect.Empty, sizeOptions)
Else
'We don't want the conversion to fail if it's not valid
Return Nothing
End If
End Function
Public Function ConvertBack(ByVal value As Object, ByVal targetType As
System.Type, ByVal parameter As Object, ByVal culture As
System.Globalization.CultureInfo) As Object Implements
System.Windows.Data.IValueConverter.ConvertBack
Throw New NotImplementedException()
End Function
End Class
This gets called using the following XAML for the Image tag:
<Image Source="{Binding Path=Photo, Converter={StaticResource ImgConv}}"
Height="24" Width="24" ></Image>
Thanks for the help
Lloyd Sheen