Clipboard can receive "image/svg+xml" Data but can not send
efef77 opened this issue · 1 comments
Problem: Clipboard can receive "image/svg+xml" Data but can not send
Background:
Since sending and receiving bitmap pictures seems to be deeply platform dependent
it is promising to use the svg format with the clipboard to externally exchange graphics.
A symmetrical consideration should promise that sending should work as receiving does.
The coding below was run under Win 11.
Receiving works just fine like this:
const string SVG = "image/svg+xml";
if (formats.Contains(SVG)) {
var svg = cb.GetDataAsync(SVG).Result;
var svgStr = System.Text.Encoding.UTF8.GetString((byte[])svg);
}
Sending the vice versa does NOT work:
const string SVG = "image/svg+xml";
var bytes = System.Text.Encoding.UTF8.GetBytes(svgString);
var data = new DataObject();
data.Set(SVG, bytes); //
cb.SetDataObjectAsync(data).Wait(); // DOES NOT END!!!
Even so this manner is NOT working:
const string SVG = "image/svg+xml";
MemoryStream stream = new MemoryStream(bytes);
var data = new DataObject();
data.Set(SVG, stream);
cb.SetDataObjectAsync(data).Wait(); // DOES NOT END!!!
Can a solution be platform independet?
Can anybody solve this problem?
Regards Friedrich