We recently updated to the community toolkit 11.1.0
Now my DrawingView can't seem to get image from stream, the arguments have changed, and I can't get it to work correctly anymore.
Original working code:
byte[] data = new byte[] { };
using (MemoryStream stream = new MemoryStream())
{
using (Stream s = await DrawingView.GetImageStream(sigPadView.Lines, new Size(sigPadView.Width, sigPadView.Height), Colors.Transparent))
{
s.CopyTo(stream);
data = stream.ToArray();
}
}
Now it is telling me it can't cast the lines from the DrawingView control to double? Looks like the arguments for DrawingView.GetImageStream() have changed, and now it wants an ImageLineOptions object.
Taking a look at ImageLineOptions, the constructor seems to take the same parameters as the DrawingView.GetImageStream() did, but I cannot seem to initialize this object. Visual studio just tells me ImageLineOptions constructor doesn't take 3 or 4 parameters, and IntelliSense refuses to show me the various overrides.
Does anyone know how to get this code working again? The documentation hasn't been updated to reflect this change yet.
Easiest conversion would be to pass ImageLineOptions, i.e.
using (Stream s = await DrawingView.GetImageStream(ImageLineOptions.FullCanvas(sigPadView.Lines, new Size(sigPadView.Width, sigPadView.Height), Colors.Transparent.AsPaint(), new Size(sigPadView.Width, sigPadView.Height))))
{
s.CopyTo(stream);
data = stream.ToArray();
}
FullCanvas needs 2 sizes, so you might want to adopt the desiredSize
/// <param name="lines">The lines that will be rendered in the resulting image.</param>
/// <param name="desiredSize">The desired dimensions of the generated image. The image will be resized proportionally.</param>
/// <param name="background">The background <see cref="Paint"/> to apply to the output image.</param>
/// <param name="canvasSize">The actual size of the canvas being displayed.</param>