I’ve been converting our old winforms project to ETO and .net7/fx, and have built a large and mostly working ETO forms GUI, project, in 4.8 it runs great but for net7.0 im stuck at the fact that since 6.0 System.Drawng.Common is no longer cross platform compatible.
in the two lines bold below im hard up against a wall. its grabbing a view from Rhino and storing it in an ETO image holder. Any suggestions?
// Capture the image from the viewport
**var capture = viewport.CaptureToBitmap(new System.Drawing.Size(width, height));**
if (capture == null)
{
RhinoApp.WriteLine("Failed to capture the viewport image.");
return null;
}
// Reselect the previously selected objects
foreach (var id in objectIds)
{
doc.Objects.Select(id);
}
// Convert the System.Drawing.Bitmap to Eto.Drawing.Bitmap
using (var stream = new MemoryStream())
{
**capture.Save(stream, System.Drawing.Imaging.ImageFormat.Png);**
stream.Position = 0;
var etoBitmap = new Eto.Drawing.Bitmap(stream);
return etoBitmap;
}
Hey @ChristopherBotha what version of Rhinocommon are you referencing and which Rhino are you testing in? This System.Drawing.Common issue is a Rhino issue, not Eto afaik. I thought this was resolved in the latest versions.
You could also include it conditionally for net7.0 as a workaround.
latest rhino 8 in both cases being referenced and used
ill convert the code to use your second method though which solves some of the issue
(i since ran itno other instances, colours inteh e.DrawXXXXX functions in displaypipeline only accept system.drawing.colors as well not eto. unless there is another workaround i missed
i tried that using et.drawing.color then within the pipeline code use .ToSystemDrawing, but that means i need to reference system.drawing which means im not cross platform compatible?
I’ve done some reading. And you’re totally right.
System.Drawing.Common doesn’t work on mac after net6.0 as mentioned in detail here.
I think @curtisw might know. I’ve done some testing and I still seem to be able to create a System.Drawing.Bitmap on mac in Rhino 8 net7.0 without issue, which makes sense as I never thought I’d had an issue doing this.
I think you should be fine using System.Drawing.Common for Rhino Plugins on Mac/Win.