Maui Community toolkit - DrawingView.GetImageStream - how to initialize ImageLineOptions? - Stack Overflow

We recently updated to the community toolkit 11.1.0Now my DrawingView can't seem to get image fro

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 badges
Add a comment  | 

1 Answer 1

Reset to default 2

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>

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744916885a4600889.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信