-
Notifications
You must be signed in to change notification settings - Fork 127
Description
Hello,
After exploring code about BitmapContext
i realized that it is trying to handle some complexity with extra lines of code. i'm not sure the purpose of this code unless it is to manage multi threaded writing to the bitmap. the managing multi thread access have cost of 30-40 lines of code also adding some complexity to the code. I think it would be better to let user handle the complexity and reduce the complexity of code, with cost of copy/pasting same extension methods which are already written for WrtiteableBitmap
, for BitmapContext
.
for explanation, an extension method WriteableBitmap.DrawLineAa(WrtiteableBitmap bitmap)
is already there, which calls the bitmap.GetBitmapContext()
and do drawing on the context. i mean copy/past this extension method for BitmapContext
too and remove codes inside BitmapContext
's constructor in order to reduce the code. final code would be look like this:
var bmp = new WriteableBitmap(500,500, blah );
var ctx = bmp.GetBitmapContext();
ctx.DrawLineAa(blah)
ctx.Dispose();
this will also allow to call ctx.DrawLineAa(blah)
from any other thread except main thread which is a good thing, also if one is trying to draw 500 lines:
for (i=0;i<500;i++)
{
var bmp = new WriteableBitmap(500,500, blah );
bmp.DrawLineAa(blah);
}
it will cause to 500 time create BitmapContext
, but
var bmp = new WriteableBitmap(500,500, blah );
using(var ctx = bmp.GetBitmapContext())
for (i=0;i<500;i++)
{
ctx.DrawLineAa(blah);
}
I think it will have higher performance, but user handles a little of complexity.
In brief
copy/pasting same extension methods which are already written for WrtiteableBitmap
, this time for BitmapContext
. it allows better multythread handling also better performance on massive drawings (#91)
If it is OK i can make the pull request, but it need massive copy-paste on many files. Just need to know if it do not break the current state of the library. Just need your confirmation to do this...