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: ffMathy **
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: ffMathy **
This is incredibly important. Right now, it's impossible in Windows Phone apps to do resizing and other heavy operations on large images in the background!