I am trying to save a PNG image that has been copied to the clipboard, but it either becomes solid black or black around areas that should be transparent.
Here is the code I use to capture and save the image
var clipboardImage = (InteropBitmap)Clipboard.GetImage(); Image.SaveImage(clipboardImage, Path.Combine(Config.App.ApplicationDataImagesPath, string.Format("{0}.{1}", imageId, "png"))); public static void SaveImage(BitmapSource bitmapImage, string filename) { using (var fileStream = new FileStream(filename, FileMode.Create)) { var pngBitmapEncoder = new PngBitmapEncoder(); pngBitmapEncoder.Frames.Add(BitmapFrame.Create(bitmapImage)); pngBitmapEncoder.Save(fileStream); fileStream.Close(); fileStream.Dispose(); } }
Does anyone have any idea why he won't look for PNG alpha channels?
thanks
Dan
Edit: I should mention that black images were executed when copying an image from Internet Explorer 9. Works great when copying an image from Chrome or Firefox. Any workarounds for IE9 issue?
source share