diff options
Diffstat (limited to 'coders/mat.c')
-rw-r--r-- | coders/mat.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/coders/mat.c b/coders/mat.c index 316692c..34577e7 100644 --- a/coders/mat.c +++ b/coders/mat.c @@ -1,5 +1,5 @@ /* -% Copyright (C) 2003-2021 GraphicsMagick Group +% Copyright (C) 2003-2023 GraphicsMagick Group % Copyright (C) 2002 ImageMagick Studio % % This program is covered by multiple licenses, which are described in @@ -171,6 +171,8 @@ static void InsertComplexDoubleRow(double *p, long y, Image *image, double MinVa if (*p > 0) { f = (*p / MaxVal) * (Quantum)(MaxRGB - q->red); /* first multiplier should be in a range <0;1> */ + if (MAGICK_ISNAN(f)) + f=0.0; /*if(f<0) f=0; */ if (f + q->red >= MaxRGB) q->red = MaxRGB; @@ -185,6 +187,8 @@ static void InsertComplexDoubleRow(double *p, long y, Image *image, double MinVa if (*p < 0) { f = (*p / MinVal) * (Quantum)(MaxRGB - q->blue); /* first multiplier should be in a range <0;1>; *p<0 and MinVal<0. */ + if (MAGICK_ISNAN(f)) + f=0.0; /*if(f<0) f=0; */ if (f + q->blue >= MaxRGB) q->blue = MaxRGB; @@ -230,6 +234,8 @@ static void InsertComplexFloatRow(float *p, long y, Image *image, double MinVal, if (*p > 0) { f = (*p / MaxVal) * (Quantum)(MaxRGB - q->red); + if (MAGICK_ISNAN(f)) + f=0.0; /*if(f<0) f=0; //Only for Assert, should be commented out */ if (f + q->red < MaxRGB) q->red += (int)f; @@ -244,6 +250,8 @@ static void InsertComplexFloatRow(float *p, long y, Image *image, double MinVal, if (*p < 0) { f = (*p / MinVal) * (Quantum)(MaxRGB - q->blue); /* f is positive only <0; inf> */ + if (MAGICK_ISNAN(f)) + f=0.0; /*if(f<0) f=0; //Only for Assert, should be commented out */ if (f + q->blue < MaxRGB) q->blue += (int) f; @@ -507,7 +515,7 @@ size_t (*ReadBlobXXXFloats)(Image *image, size_t len, float *data); HDR.Type[3] = ldblk % 10; ldblk /= 10; /* T digit */ HDR.Type[2] = ldblk % 10; ldblk /= 10; /* P digit */ HDR.Type[1] = ldblk % 10; ldblk /= 10; /* O digit */ - HDR.Type[0] = ldblk; /* M digit */ + HDR.Type[0] = (unsigned char)ldblk; /* M digit */ if(HDR.Type[3]!=0) RET_CHECK(image); /* Data format */ if(HDR.Type[2]!=0) RET_CHECK(image); /* Always 0 */ @@ -721,8 +729,7 @@ size_t (*ReadBlobXXXFloats)(Image *image, size_t len, float *data); rotated_image->blob = image->blob; rotated_image->colors = image->colors; image->blob = blob; - AppendImageToList(&image,rotated_image); - DeleteImageFromList(&image); + ReplaceImageInList(&image,rotated_image); image = rotated_image; } @@ -1295,8 +1302,7 @@ ExitLoop: rotated_image->blob = image->blob; rotated_image->colors = image->colors; image->blob = blob; - AppendImageToList(&image,rotated_image); - DeleteImageFromList(&image); + ReplaceImageInList(&image,rotated_image); } skip_reading_current: @@ -1462,7 +1468,7 @@ static MagickPassFail WriteMATLABImage(const ImageInfo *image_info,Image *image) Store MAT header. */ (void) memset(MATLAB_HDR,' ',Min(sizeof(MATLAB_HDR),124)); - sprintf(MATLAB_HDR,"MATLAB 5.0 MAT-file, Platform: %.8s, Created on: %.3s %.3s %2d %2d:%2d:%2d %d", + snprintf(MATLAB_HDR,sizeof(MATLAB_HDR),"MATLAB 5.0 MAT-file, Platform: %.8s, Created on: %.3s %.3s %2d %2d:%2d:%2d %d", OsDesc, DayOfWTab[t->tm_wday], MonthsTab[t->tm_mon], |