1

I have argb bitmap. I would like to copy to clipboard. Why doesn't my code work?

var enc = new PngBitmapEncoder();
using (var ms = new MemoryStream())
{
     enc.Frames.Add(BitmapFrame.Create((BitmapSource)Img.Source));
     enc.Save(ms);
     BitmapImage bi = new BitmapImage();
     bi.BeginInit();
     bi.StreamSource = ms;
     bi.EndInit();
     Clipboard.SetImage(bi);
}

1 Answers1

0

The Windows clipboard, by default, does not support transparency, but you can put content on the clipboard in many types together to make sure most applications find some type in it that they can use. Generally, if, in addition to the normal nontransparent clipboard Bitmap format, you put the image on the clipboard in both PNG and DIB formats, most applications will be able to use at least one of them to get the image in a format they support as being transparent.

There is already an answer: Copying From and To Clipboard loses image transparency

S.Spieker
  • 7,005
  • 8
  • 44
  • 50