Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggesting major modification #92

Open
epsi1on opened this issue Nov 6, 2024 · 0 comments
Open

Suggesting major modification #92

epsi1on opened this issue Nov 6, 2024 · 0 comments

Comments

@epsi1on
Copy link
Contributor

epsi1on commented Nov 6, 2024

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...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant