Skip to content

Improve DrawImageAlpha to not use a new Pen every time#2314

Merged
quajak merged 3 commits into
CosmosOS:masterfrom
retrievaaaa:patch-DrawImageAlpha
Jun 29, 2022
Merged

Improve DrawImageAlpha to not use a new Pen every time#2314
quajak merged 3 commits into
CosmosOS:masterfrom
retrievaaaa:patch-DrawImageAlpha

Conversation

@retrievaaaa

@retrievaaaa retrievaaaa commented Jun 26, 2022

Copy link
Copy Markdown
Contributor

Currently, Canvas.DrawImageAlpha always creates a new Pen. For every pixel. This PR changes it so that there is one Pen, created at the beginning of the method. Each pixel just changes the color, which improves performance. My kernel with ~15 alpha images went from 15 fps to 24 fps

@quajak quajak left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice optimisation! Could you please also add the trick to the normal DrawImage in Canvas.cs

@retrievaaaa

Copy link
Copy Markdown
Contributor Author

Done

@retrievaaaa retrievaaaa requested a review from quajak June 29, 2022 20:15

@quajak quajak left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@quajak quajak merged commit 67b9c8b into CosmosOS:master Jun 29, 2022
@retrievaaaa retrievaaaa deleted the patch-DrawImageAlpha branch July 9, 2022 12:07
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

Successfully merging this pull request may close these issues.

2 participants