You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
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...
The text was updated successfully, but these errors were encountered:
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 forWrtiteableBitmap
, forBitmapContext
.for explanation, an extension method
WriteableBitmap.DrawLineAa(WrtiteableBitmap bitmap)
is already there, which calls thebitmap.GetBitmapContext()
and do drawing on the context. i mean copy/past this extension method forBitmapContext
too and remove codes insideBitmapContext
's constructor in order to reduce the code. final code would be look like this: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:it will cause to 500 time create
BitmapContext
, butI 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 forBitmapContext
. 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...
The text was updated successfully, but these errors were encountered: