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

DrawBitmap support for ICanvas #4094

Open
BharanikhumarSR opened this issue Jan 12, 2022 · 5 comments
Open

DrawBitmap support for ICanvas #4094

BharanikhumarSR opened this issue Jan 12, 2022 · 5 comments
Labels
area-drawing Shapes, Borders, Shadows, Graphics, BoxView, custom drawing proposal/open t/enhancement ☀️ New feature or request
Milestone

Comments

@BharanikhumarSR
Copy link

BharanikhumarSR commented Jan 12, 2022

Description

In terms of drawing using ICanvas I feel features are bit limited on MAUI. Drawing on bitmap would be lot easier to save the UI and reuse object whenever needed.

For example, here is a case where I have tried to render circle based on the touch points interacted and for this I need to store every points and render again for each interaction. This results in performance issues on higher point counts. So I have overcame this issue on android native by drawing the points on bitmap parallelly and rendered the existing bitmap to the view on each interaction. So this lets canvas draw the bitmap alone at invalidate. So it would be good to provide feature to draw on the bitmap and draw a bitmap to the view using ICanvas.

Public API Changes

  • canvas.DrawBitmap(bitmap) -Renders bitmap to the given canvas
  • canvas.DrawCircle(bitmap) -Render on the bitmap object

Intended Use-Case

In my app I have a situation where I would add different paths to the canvas. But adding each paths every time at invalidation costs me the performance issue. Drawing on the bitmap and drawing the same bitmap to the view would be lot performance savings

@BharanikhumarSR BharanikhumarSR changed the title Bitmap conversion and rendering support for ImageSource DrawBitamp support for ICanvas Jan 12, 2022
@BharanikhumarSR BharanikhumarSR changed the title DrawBitamp support for ICanvas DrawBitmap support for ICanvas Jan 12, 2022
@jsuarezruiz jsuarezruiz added the area-drawing Shapes, Borders, Shadows, Graphics, BoxView, custom drawing label Jan 12, 2022
@jsuarezruiz jsuarezruiz added this to Under consideration in Enhancements Jan 12, 2022
@jsuarezruiz jsuarezruiz added the t/enhancement ☀️ New feature or request label Jan 12, 2022
@v-longmin
Copy link

Thank you so much for your bug report! Unfortunately, we cannot reproduce your issue with the information above, could you provide a sample project and screenshots or more details that we can reproduce your issue? That should greatly speed up the process, thanks!

@v-longmin v-longmin added s/triaged Issue has been reviewed s/needs-repro Attach a solution or code which reproduces the issue labels Mar 4, 2022
@ghost
Copy link

ghost commented Mar 4, 2022

Hi @BharanikhumarSR. We have added the "s/needs-repro" label to this issue, which indicates that we require steps and sample code to reproduce the issue before we can take further action. Please try to create a minimal sample project/solution or code samples which reproduce the issue, ideally as a GitHub repo that we can clone. See more details about creating repros here: https://github.com/dotnet/maui/blob/main/.github/repro.md

This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

@PureWeen PureWeen removed the s/needs-repro Attach a solution or code which reproduces the issue label Mar 4, 2022
@hartez
Copy link
Contributor

hartez commented Mar 4, 2022

@BharanikhumarSR sorry for the confusion, we now realize this was a feature proposal and not a bug report. You can ignore the comments from the msftbot account - this won't be closed.

@jsuarezruiz jsuarezruiz added this to the .NET 7 milestone Mar 23, 2022
@SheepReaper
Copy link

SheepReaper commented Apr 23, 2022

I've run into this problem as well. I'd like to just draw to a bitmap and then draw the bitmap to the canvas, but can't figure out how to do it without platform code. I'm looking at IImage or IPicture instead. I don't need to read from file, I just need this buffer to exist in memory to save on canvas draw operations.

One other way I've thought of doing it is with parallel linq, but the canvas really doesn't want to be accessed like this. Next step i guess is to clone the canvas for the draw operations, but this is rabbit-hole-ing rather quickly.

The end goal here is to take an array of pixels and blit them to the canvas, but just stumbling my way there. DrawImage() looks like what I want, but not sure how to get that IImage....

here's my sample: https://github.com/SheepReaper/ParallelDrawOnCanvas
flip my comments in DrawableBase to see the broken parallel.

This was inspired by my wanting to do a fully MAUI non-skia version of this: https://swharden.com/blog/2021-09-10-maui-graphics/

So my paths right now, if anyone knows how:

  • Create an IImage without reading from file, somehow reacting to canvas size changes (not necessary for final solution)
  • Draw on ICanvas in parallel

@Redth Redth modified the milestones: .NET 7 + Servicing, Backlog Aug 30, 2022
@ghost
Copy link

ghost commented Aug 30, 2022

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

@samhouts samhouts removed the s/triaged Issue has been reviewed label Apr 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-drawing Shapes, Borders, Shadows, Graphics, BoxView, custom drawing proposal/open t/enhancement ☀️ New feature or request
Projects
Enhancements
Under consideration
Development

No branches or pull requests

8 participants