Merge pull request #4833 from larsbrubaker/master
Don't process bad images
This commit is contained in:
commit
f60aeab8eb
2 changed files with 10 additions and 3 deletions
|
|
@ -92,17 +92,19 @@ namespace MatterHackers.MatterControl
|
|||
var expectedCachePath = this.CachePath(libraryItem, width, height);
|
||||
|
||||
ImageBuffer cachedItem = LoadImage(expectedCachePath);
|
||||
if(cachedItem != null)
|
||||
if (cachedItem != null
|
||||
&& cachedItem.Width > 0 && cachedItem.Height > 0)
|
||||
{
|
||||
cachedItem.SetRecieveBlender(new BlenderPreMultBGRA());
|
||||
return cachedItem;
|
||||
}
|
||||
|
||||
// if we don't find it see if it is in the cache at a bigger size
|
||||
foreach(var cacheSize in cacheSizes.Where(s => s > width))
|
||||
foreach (var cacheSize in cacheSizes.Where(s => s > width))
|
||||
{
|
||||
cachedItem = LoadImage(this.CachePath(libraryItem, cacheSize, cacheSize));
|
||||
if(cachedItem != null)
|
||||
if (cachedItem != null
|
||||
&& cachedItem.Width > 0 && cachedItem.Height > 0)
|
||||
{
|
||||
cachedItem = cachedItem.CreateScaledImage(width, height);
|
||||
cachedItem.SetRecieveBlender(new BlenderPreMultBGRA());
|
||||
|
|
|
|||
|
|
@ -201,6 +201,11 @@ namespace MatterHackers.MatterControl.Library
|
|||
{
|
||||
if (icon != null)
|
||||
{
|
||||
if (icon.Width == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
icon = await Task.Run(() => this.EnsureCorrectThumbnailSizing(icon, thumbWidth, thumbHeight));
|
||||
thumbnailListener?.Invoke(icon);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue