Clipboard.GetImage() handling webp.

Im trying to save copied image from clipboard to file, problem is if that image is .webp it is all black pixels. I tried pngencoder, using writablebitmap, skiasharp... I think the bitmapsource cant handle webp as Clipboard.GetImage() returns BItmapSource? Any ideas?
2 Replies
Angius
Angius3w ago
IIRC the Winforms Clipboard can only handle bitmaps without transparency Think you'll have to try using Clipboard.GetData() Actually, this website looks... odd, but seems it has a good idea: https://csharphelper.com/howtos/howto_paste_png.html
MCUnderground
MCUndergroundOP3w ago
Im using WPF Clipboard, tho i realized, any image copied from internet is blank, it holds data like resolution but blank image. WPF seems to support transparency on Clipboard. Tho i went the route to check if it is a Dip or Bitmap, and it is Dip, it goes to that if statement if i set it first, it returns a memorystream, but i dont know what to do with that memorystream as trying to convert it to bitmapsource fails. And it goes to my next check if it is filedrop and it is, so it stores the image path(when you copy image from web, it goes to temp folder as "Untitled"). So the Clipboard passes for both Dip, Bitmap, GetImage() and GetFileDropList() if you copy image from the web. Weird.

Did you find this page helpful?