admin管理员组文章数量:1410730
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.
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.
Share asked Mar 7 at 17:00 ShabobooShaboboo 1,5931 gold badge18 silver badges39 bronze badges1 Answer
Reset to default 2Easiest 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>
本文标签: Maui Community toolkitDrawingViewGetImageStreamhow to initialize ImageLineOptionsStack Overflow
版权声明:本文标题:Maui Community toolkit - DrawingView.GetImageStream - how to initialize ImageLineOptions? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744916885a2632049.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论