Improv lithophane stability

This commit is contained in:
Lars Brubaker 2021-03-08 18:01:19 -08:00
parent 3c9a9d75f3
commit 005b868c4d
2 changed files with 17 additions and 1 deletions

View file

@ -31,6 +31,7 @@ using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Threading.Tasks;
using MatterHackers.Agg;
using MatterHackers.Agg.Platform;
using MatterHackers.Agg.UI;
using MatterHackers.DataConverters3D;
@ -92,6 +93,21 @@ namespace MatterHackers.MatterControl.Plugins.Lithophane
this.DebugDepth("Rebuild");
var activeImage = this.ImageChild.Image;
if (activeImage == null
|| activeImage.Width == 0
|| activeImage.Height == 0)
{
return Task.CompletedTask;
}
activeImage.GetVisibleBounds(out RectangleInt visibleBounds);
if (visibleBounds.Width == 0
|| visibleBounds.Height == 0)
{
return Task.CompletedTask;
}
ApplicationController.Instance.Tasks.Execute("Generating Lithophane".Localize(), null, (reporter, cancellationToken) =>
{
var generatedMesh = Lithophane.Generate(