I have a weird problem saving clipboard image for png. When shooting using the prtscr or snipping tool, it works great with Clipboard.GetImage () and PngBitmapEncoder. But when copying an image from Paint and doing the same result, I get an empty image. At least it looks blank when you try to view it, although it seems to contain valid PNG image data. When using Jpeg-encoder, it works great. What is the problem with PNG and Paint? Does this have anything to do with transparency?
Update to clarify: Im extracting the image from the clipboard. I just can't save it to disk using PNGEncoder if the image was copied from Paint in the first place. I can save paint-clipboard images using JpegEncoder, though ... but I want to use PNG.
BitmapSource source = Clipboard.GetImage(); PngBitmapEncoder enc = new PngBitmapEncoder(); enc.Frames.Add(BitmapFrame.Create(source)); enc.Save(stream);
Above the code, an image file is created with invisible content completely dependent on the viewer (when copying from ctrl-c from Paint). It makes me think it has something to do with transparency ...
source share