How can I get an image out of the clipboard without losing the alpha channel in .NET?

前端 未结 4 1288
旧时难觅i
旧时难觅i 2020-12-06 06:44

I\'m trying to save a copied image from the clipboard but it\'s losing its alpha channel:

Image clipboardImage = Clipboard.GetImage();
string imagePath = Pat         


        
4条回答
  •  一个人的身影
    2020-12-06 07:24

    I am just using Forms methode. Its not that nice solution like using GetFormat like Kevin is telling us but its more quick and works quiete well at all.

      'Dim bm As BitmapSource = Clipboard.GetImage()'looses alpha channel
                    'Dim bmS As New WriteableBitmap(bm)'does work but still without alpha information
                    Dim bmF As System.Drawing.Bitmap = System.Windows.Forms.Clipboard.GetImage 'Get working image
                    Dim bmS As BitmapSource = TB.Imaging.WPF.BitmapToWpfBitmapSource(bmF, Me) 'convert Bitmap into BitmapSource
                    Me.Source = bmS
    

提交回复
热议问题