As ThePhantomUpvoter correctly pointed out, the clipboard has no color. :-)
You need to change the background of the image before you copy it with
Clipboard.SetImage
. Then you can restore it.
If you use the clipboard just to put data in the rich text box, this is a very dirty method, because you interfere with other possible uses of the clipboard. You can write to rich text box content directly, using its format, which is publicly available:
http://en.wikipedia.org/wiki/Rich_Text_Format[
^],
http://www.microsoft.com/en-us/download/details.aspx?id=10725[
^].
I remember one answer of one CodeProject member who demonstrated the code doing it. However, I don't want to search for this CodeProject link. First, you can do it by yourself. More importantly, RTF format is very awkward to work with and pretty much obsolete. I would advise to use something else: HTML, Microsoft Office Open XML or open-source OpenDocument:
http://en.wikipedia.org/wiki/Open_XML[
^],
http://en.wikipedia.org/wiki/OpenDocument[
^].
The standards are well documented, there are APIs you can use. Interested?
Now, as to HTML. There is a perfect CodeProject component which will render HTML document for you, without using the
WebBrowser
control. You can even use hrefs to embedded resources, including images. Please see:
A Professional HTML Renderer You Will Use[
^].
By the way, you don't need
PictureBox
at all. You need a bitmap (in other cases, you need direct rendering of graphics). Why you guys always use this nearly useless control, even in cases when it does not help at all, only presents hassles?!
—SA