Hi,
So I am trying to add some code for the user to copy a Unity editor icon and paste it somewhere else. I managed to get it working but the background transparency is missing.
Here is the code:
using (Stream s = new MemoryStream(IconImage.width * IconImage.height))
{
Texture2D textreCopy = new(IconImage.width, IconImage.height, IconImage.format, IconImage.mipmapCount > 1);
Graphics.CopyTexture(IconImage, textreCopy);
byte[] bits = textreCopy.EncodeToPNG();
s.Write(bits, 0, bits.Length);
System.Drawing.Image image = System.Drawing.Image.FromStream(s);
System.Windows.Forms.Clipboard.SetImage(image);
}
I found out that the textreCopy variable is storing the correct alpha value but it is getting lost when using System.Drawing.Image.FromStream(s). I also tried to convert the colour information from the texture from RGBA to ARGB but this did not fix the issue.
Any help is appreciated.