If many shapes need to be drawn, it's dramatically faster if a local reference to the Pixels array is passed to the methods directly.
int[] pixels = writeableBmp.Pixels;
int w = writeableBmp.PixelsWidth;
int h = writeableBmp.PixelsHeight;
for(int i = 0; i < 10000; i++)
{
DrawLine(pixels, w, h, ...);
}
is much faster than
for(int i = 0; i < 10000; i++)
{
DrawLine(writeableBmp, ...);
}
Another important point is multi-threading. The WriteableBitmap cannot be used in a background thread (Exception is thrown).
Comments: ** Comment from web user: teichgraf **
int[] pixels = writeableBmp.Pixels;
int w = writeableBmp.PixelsWidth;
int h = writeableBmp.PixelsHeight;
for(int i = 0; i < 10000; i++)
{
DrawLine(pixels, w, h, ...);
}
is much faster than
for(int i = 0; i < 10000; i++)
{
DrawLine(writeableBmp, ...);
}
Another important point is multi-threading. The WriteableBitmap cannot be used in a background thread (Exception is thrown).
Comments: ** Comment from web user: teichgraf **
We just have it for a few methods right now and won't have the time to add it soon, but we appreciate code contributions. :)
- Rene