Make sure we are thread safe

This commit is contained in:
LarsBrubaker 2020-09-10 09:50:33 -07:00
parent 54c3cdedea
commit 26bb26884f
5 changed files with 37 additions and 19 deletions

View file

@ -401,7 +401,7 @@ namespace MatterHackers.MatterControl.CustomWidgets
}
}
public static void ResizeCanvas(ImageBuffer originalImage, int width, int height)
public static ImageBuffer ResizeCanvas(ImageBuffer originalImage, int width, int height)
{
var destImage = new ImageBuffer(width, height, 32, originalImage.GetRecieveBlender());
@ -419,9 +419,7 @@ namespace MatterHackers.MatterControl.CustomWidgets
renderGraphics.FillRectangle(center, Color.Transparent);
originalImage.Allocate(width, height, 32, originalImage.GetRecieveBlender());
originalImage.CopyFrom(destImage);
return destImage;
}
private void ListViewItem_DoubleClick(object sender, MouseEventArgs e)

View file

@ -121,6 +121,12 @@ namespace MatterHackers.MatterControl.CustomWidgets
requeueRaytraceOnDraw = false;
raytracePending = false;
if (GuiWidget.DeviceScale != 1
&& thumbnail.Width != thumbWidth * GuiWidget.DeviceScale)
{
thumbnail = thumbnail.CreateScaledImage(GuiWidget.DeviceScale);
}
if (thumbnail.Width != thumbWidth
|| thumbnail.Height != thumbHeight)
{
@ -199,7 +205,11 @@ namespace MatterHackers.MatterControl.CustomWidgets
ApplicationController.Instance.Library.EnsureCorrectThumbnailSizing(
thumbnail,
thumbWidth,
thumbHeight));
thumbHeight,
(image) =>
{
SetSizedThumbnail(image);
}));
}
private void SetSizedThumbnail(ImageBuffer thumbnail)