-
Notifications
You must be signed in to change notification settings - Fork 405
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
Enhance DrawingView and DrawingViewService to provide the ability to export the full image size #2193
base: main
Are you sure you want to change the base?
Conversation
@VladislavAntonyuk what do you think to this approach to enable developers to export the whole canvas should they wish? It needs to be completed for all platforms but I have the PoC working for Apple platforms |
Thanks @bijington , looks good. What do you think about renaming imageSize to lineBounds? Because ImageSize and CanvasSize may be confused. |
@VladislavAntonyuk great idea! I will carry on then and include that suggestion thanks. Also sadly I can't work out how to make this non breaking so I'll add the breaking label |
To make it not a breaking change, we can move the canvasSize parameter to the last position, but it's not good to have something after CancellationToken. However, I don't think it's a problem as we had breaking changes before. We can probably merge it with .net 9 support |
I did originally try that but one of our analysis rules complained as it is 'best practise' to keep the |
Or I guess rather than a default parameter we have an overload and therefore the current behaviour will stay as the default... That might work |
…CommunityToolkit/Maui into feature/sl-1397-drawing-view-full-image
The latest push removes the breaking nature of this PR |
FYI I haven't tested Android, Windows or Tizen yet. The last 2 I wrote on a Mac so I don't even know if it compiles yet... |
I am unable to test on Windows or Tizen right now as my home network is down while we do some renovations. If anyone can test either platform that would be really helpful. Otherwise I will move onto the docs |
/// <param name="background">Image background</param> | ||
/// <param name="token"><see cref="CancellationToken"/></param> | ||
/// <returns>Image stream</returns> | ||
public static ValueTask<Stream> GetImageStream(IList<PointF> points, Size desiredSize, float lineWidth, Color strokeColor, Paint? background, CancellationToken token = default) => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about moving parameters in Options class?
So new method signature looks like this:
public static ValueTask<Stream> GetImageStream(IList<PointF> points, Size desiredSize, float lineWidth, Color strokeColor, Paint? background, CancellationToken token = default) => | |
public static ValueTask<Stream> GetImageStream(IList<PointF> points, ImageOptions options, CancellationToken token = default) |
In this case we may easily extend image options without breaking changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great idea!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 5 out of 15 changed files in this pull request and generated no suggestions.
Files not reviewed (10)
- samples/CommunityToolkit.Maui.Sample/Pages/Views/DrawingViewPage.xaml: Language not supported
- samples/CommunityToolkit.Maui.Sample/Pages/Views/DrawingViewPage.xaml.cs: Evaluated as low risk
- samples/CommunityToolkit.Maui.Sample/ViewModels/Views/DrawingViewViewModel.cs: Evaluated as low risk
- src/CommunityToolkit.Maui.Core/Interfaces/IDrawingLine.shared.cs: Evaluated as low risk
- src/CommunityToolkit.Maui.Core/Interfaces/IDrawingView.shared.cs: Evaluated as low risk
- src/CommunityToolkit.Maui.Core/Primitives/DrawingViewOutputOption.shared.cs: Evaluated as low risk
- src/CommunityToolkit.Maui.Core/Views/DrawingView/DrawingLine.shared.cs: Evaluated as low risk
- src/CommunityToolkit.Maui.Core/Views/DrawingView/Service/DrawingViewService.android.cs: Evaluated as low risk
- src/CommunityToolkit.Maui.Core/Views/DrawingView/Service/DrawingViewService.macios.cs: Evaluated as low risk
- src/CommunityToolkit.Maui.Core/Views/DrawingView/Service/DrawingViewService.net.cs: Evaluated as low risk
Description of Change
The aim of this PR is to allow developers to export their drawings in multiple ways:
The following image shows the result in the Files app in the simulator on iOS based on using the sample application from the toolkit.
The change allows a developer to provide an
ImageOutputOption
value to theDrawingView
:This will then pass into the
DrawingViewService
the bounds of the currentDrawingView
. Developers can then also supply their out dimensions should they wish to theDrawingViewService
.Linked Issues
PR Checklist
approved
(bug) orChampioned
(feature/proposal)main
at time of PRAdditional information