Make it possible to set the blender on the AsyncLoad widget
Fixed a crash with an empty queue
This commit is contained in:
parent
c31103a0d5
commit
bf2484cdc3
3 changed files with 26 additions and 14 deletions
|
|
@ -52,6 +52,9 @@ namespace MatterHackers.MatterControl
|
|||
bool startedLoad = false;
|
||||
string uriToLoad;
|
||||
|
||||
IRecieveBlenderByte scalingBlender = new BlenderBGRA();
|
||||
public void SetScalingBlender(IRecieveBlenderByte blender) { scalingBlender = blender; }
|
||||
|
||||
public ImageWidget_AsyncLoadOnDraw(ImageBuffer image, string uriToLoad)
|
||||
: base(image)
|
||||
{
|
||||
|
|
@ -89,7 +92,7 @@ namespace MatterHackers.MatterControl
|
|||
// The image sampler we use is a 2x2 filter so we need to scale by a max of 1/2 if we want to get good results.
|
||||
// So we scale as many times as we need to to get the Image to be the right size.
|
||||
// If this were going to be a non-uniform scale we could do the x and y separatly to get better results.
|
||||
ImageBuffer halfImage = new ImageBuffer(unScaledImage.Width / 2, unScaledImage.Height / 2, 32, new BlenderBGRA());
|
||||
ImageBuffer halfImage = new ImageBuffer(unScaledImage.Width / 2, unScaledImage.Height / 2, 32, scalingBlender);
|
||||
halfImage.NewGraphics2D().Render(unScaledImage, 0, 0, 0, halfImage.Width / (double)unScaledImage.Width, halfImage.Height / (double)unScaledImage.Height);
|
||||
unScaledImage = halfImage;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -113,7 +113,10 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
|
||||
public override void OnClosed(EventArgs e)
|
||||
{
|
||||
activePrintPreviewImage.PrintItem.SlicingOutputMessage -= PrintItem_SlicingOutputMessage;
|
||||
if (activePrintPreviewImage.PrintItem != null)
|
||||
{
|
||||
activePrintPreviewImage.PrintItem.SlicingOutputMessage -= PrintItem_SlicingOutputMessage;
|
||||
}
|
||||
if (unregisterEvents != null)
|
||||
{
|
||||
unregisterEvents(this, null);
|
||||
|
|
|
|||
|
|
@ -136,15 +136,17 @@ namespace MatterHackers.MatterControl
|
|||
get { return printItem; }
|
||||
set
|
||||
{
|
||||
if (printItem != null)
|
||||
if (PrintItem != null)
|
||||
{
|
||||
printItem.FileHasChanged -= item_FileHasChanged;
|
||||
PrintItem.FileHasChanged -= item_FileHasChanged;
|
||||
}
|
||||
|
||||
printItem = value;
|
||||
|
||||
thumbNailHasBeenCreated = false;
|
||||
if (printItem != null)
|
||||
if (PrintItem != null)
|
||||
{
|
||||
printItem.FileHasChanged += item_FileHasChanged;
|
||||
PrintItem.FileHasChanged += item_FileHasChanged;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -170,9 +172,10 @@ namespace MatterHackers.MatterControl
|
|||
{
|
||||
unregisterEvents(this, null);
|
||||
}
|
||||
if (printItem != null)
|
||||
|
||||
if (PrintItem != null)
|
||||
{
|
||||
printItem.FileHasChanged -= item_FileHasChanged;
|
||||
PrintItem.FileHasChanged -= item_FileHasChanged;
|
||||
}
|
||||
base.OnClosed(e);
|
||||
}
|
||||
|
|
@ -477,12 +480,15 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
private void OnDoneRendering()
|
||||
{
|
||||
string stlHashCode = this.PrintItem.FileHashCode.ToString();
|
||||
string imageFileName = GetImageFileName(stlHashCode);
|
||||
|
||||
if (DoneRendering != null)
|
||||
if (PrintItem != null)
|
||||
{
|
||||
DoneRendering(this, new StringEventArgs(imageFileName));
|
||||
string stlHashCode = this.PrintItem.FileHashCode.ToString();
|
||||
string imageFileName = GetImageFileName(stlHashCode);
|
||||
|
||||
if (DoneRendering != null)
|
||||
{
|
||||
DoneRendering(this, new StringEventArgs(imageFileName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -582,7 +588,7 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
private bool SetImageFast()
|
||||
{
|
||||
if (this.printItem == null)
|
||||
if (this.PrintItem == null)
|
||||
{
|
||||
this.thumbnailImage = new ImageBuffer(this.noThumbnailImage);
|
||||
this.Invalidate();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue