Check for null design and valid bitmap size when updating image, should fix issue #5

Branch_2.1.x
Nathan Crawford 2015-12-21 21:09:57 -05:00
rodzic e2604752e6
commit 0f11f3c63d
1 zmienionych plików z 12 dodań i 0 usunięć

Wyświetl plik

@ -148,6 +148,12 @@ namespace embroideryReader
private void updateDesignImage()
{
if(design == null)
{
// No design loaded - nothing to update
return;
}
Bitmap tempImage = design.designToBitmap((float)settings.threadThickness, (settings.filterStiches), settings.filterStitchesThreshold, 1.0f);
// Rotate image
@ -187,6 +193,12 @@ namespace embroideryReader
int width = (int)(tempImage.Width * designScale);
int height = (int)(tempImage.Height * designScale);
if (width < 1 || height < 1)
{
// Image area is too small to update
return;
}
if (width != tempImage.Width || height != tempImage.Height)
{
// Scale image code from http://stackoverflow.com/questions/1922040/resize-an-image-c-sharp