WPF Projelerinizde resource dosyasindan resim(image) okumaniz ve kullanmaniz icin fonksiyonlar

WPF Projelerinizde resource dosyasindan resim(image) okumaniz ve kullanmaniz icin fonksiyonlar

Private Function Bmp2MediaImage(ByVal Resourceimage As System.Drawing.Bitmap) As System.Windows.Media.ImageSource
Dim bmp As System.Drawing.Bitmap = New System.Drawing.Bitmap(Resourceimage)
Dim hBitmap As IntPtr = bmp.GetHbitmap
Dim imageSource As System.Windows.Media.ImageSource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(hBitmap, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions)
Return imageSource
End Function
Private Function StreamBmp2MediaImage(ByVal Stream As System.IO.Stream) As System.Windows.Media.ImageSource
Dim bmp As System.Drawing.Bitmap = System.Drawing.Bitmap.FromStream(Stream)
Dim hBitmap As IntPtr = bmp.GetHbitmap
Dim imageSource As System.Windows.Media.ImageSource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(hBitmap, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions)
Return imageSource
End Function

Bir Cevap Yazın