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

前端 未结 4 1282
旧时难觅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:31

    The image is being saved as a bitmap where the transparent pixels are visible on the clipboard so use this code

    Bitmap clipboardImage = Clipboard.GetImage();
    clipboardImage.MakeTransparent()
    string imagePath = Path.GetTempFileName();
    clipboardImage.Save(imagePath);
    

提交回复
热议问题