the following part is very slow in C#
for (int i = 0; i < stream.Length / 4; i++)
{
//write Color4 doesn't work for this
stream.Write(colors[i].ToArgb());
}
I had a project where I did this part in an managed c++ dll, it was very very fast.
an other idea:
{
texture.LockRectangle(0, LockFlags.None, out stream); // fixed
var bitmap = new Bitmap(width, height, width * 4, PixelFormat.Format32bppPArgb, stream.DataPointer);
var graphics = Graphics.FromImage(bitmap);
graphics.Clear(color);
graphics.Dispose();
texture.UnlockRectangle(0);
graphicsbitmap.Dispose();
}Something like this, has extra costs because of the bitmap creating and graphics. But the graphics.Clear ist much much faster than the for (int i = 0; i < stream.Length / 4; i++).
Anyone a better solution?