diff options
Diffstat (limited to 'magick/constitute.c')
-rw-r--r-- | magick/constitute.c | 75 |
1 files changed, 65 insertions, 10 deletions
diff --git a/magick/constitute.c b/magick/constitute.c index a25389b..165aec6 100644 --- a/magick/constitute.c +++ b/magick/constitute.c @@ -1,5 +1,5 @@ /* -% Copyright (C) 2003 - 2020 GraphicsMagick Group +% Copyright (C) 2003 - 2022 GraphicsMagick Group % Copyright (C) 2002 ImageMagick Studio % % This program is covered by multiple licenses, which are described in @@ -569,7 +569,8 @@ MagickExport Image *ConstituteImage(const unsigned long width, } } } - indexes++; + if (NULL != (IndexPacket *) indexes) + indexes++; q++; } if (!SyncImagePixels(image)) @@ -1444,17 +1445,17 @@ static void RemoveTemporaryInputFile(ImageInfo *image_info) (LocaleCompare(image_info->filename+filename_length-4,".mpc") == 0)) { char remove_name[MaxTextExtent]; - (void) strcpy(remove_name,image_info->filename); + (void) strlcpy(remove_name,image_info->filename,sizeof(remove_name)); remove_name[filename_length-4]=0; - (void) strcat(remove_name,".cache"); + (void) strlcat(remove_name,".cache",sizeof(remove_name)); (void) printf("removing %s\n", remove_name); (void) remove(remove_name); } else if (LocaleCompare(image_info->magick,"mpc") == 0) { char remove_name[MaxTextExtent]; - (void) strcpy(remove_name,image_info->filename); - (void) strcat(remove_name,".cache"); + (void) strlcpy(remove_name,image_info->filename,sizeof(remove_name)); + (void) strlcat(remove_name,".cache",sizeof(remove_name)); (void) printf("removing %s\n", remove_name); (void) remove(remove_name); } @@ -1462,6 +1463,57 @@ static void RemoveTemporaryInputFile(ImageInfo *image_info) errno=0; } +/* + Test if image list is a simple ordered list already in the bounds of + subimage/subrange or if it needs to be reconciled. +*/ +static MagickBool MagickReconcileListNeeded(const Image* image, const ImageInfo *image_info) MAGICK_FUNC_PURE; +static MagickBool MagickReconcileListNeeded(const Image* image, const ImageInfo *image_info) +{ + const Image + *list; + + const unsigned long + min_scene = image_info->subimage, + max_scene = image_info->subimage+image_info->subrange; + + MagickBool + res = MagickFalse; + + do + { + if (strchr(image_info->tile, ',') != (char *) NULL) + { + res=MagickTrue; + break; + } + + for (list = image; list != (Image *) NULL; list=list->next) + { + if (!(list->scene >= min_scene)) + { + res=MagickTrue; + break; + } + + if (!(list->scene < max_scene)) + { + res=MagickTrue; + break; + } + + if ((list->next) && (list->scene+1 != list->next->scene)) + { + res=MagickTrue; + break; + } + } + + } while (0); + + return res; +} + MagickExport Image *ReadImage(const ImageInfo *image_info, ExceptionInfo *exception) { @@ -1633,6 +1685,7 @@ MagickExport Image *ReadImage(const ImageInfo *image_info, if (image != (Image *) NULL) { + image=GetFirstImageInList(image); (void) LogMagickEvent(CoderEvent,GetMagickModule(), "Returned from \"%.1024s\" decoder: frames=%lu cache=%s" " monochrome=%s grayscale=%s class=%s colorspace=%s", @@ -1749,6 +1802,7 @@ MagickExport Image *ReadImage(const ImageInfo *image_info, if (image != (Image *) NULL) { + image=GetFirstImageInList(image); (void) LogMagickEvent(CoderEvent,GetMagickModule(), "Returned from \"%.1024s\" decoder: frames=%lu" " cache=%s monochrome=%s grayscale=%s class=%s" @@ -1817,7 +1871,8 @@ MagickExport Image *ReadImage(const ImageInfo *image_info, if (GetBlobTemporary(image)) RemoveTemporaryInputFile(clone_info); - if ((image->next != (Image *) NULL) && IsSubimage(clone_info->tile,False)) + if ((image->next != (Image *) NULL) && IsSubimage(clone_info->tile,False) && + MagickReconcileListNeeded(image,clone_info)) { char *q; @@ -2167,7 +2222,7 @@ WriteImage(const ImageInfo *image_info,Image *image) assert(image->signature == MagickSignature); if (LocaleNCompare(image_info->magick,"INFO",sizeof("INFO")-1)) GetTimerInfo(&image->timer); - image->logging=IsEventLogging(); + image->logging=IsEventLogged(CoderEvent); clone_info=CloneImageInfo(image_info); (void) strlcpy(clone_info->filename,image->filename,MaxTextExtent); (void) strlcpy(clone_info->magick,image->magick,MaxTextExtent); @@ -2402,7 +2457,7 @@ WriteImages(const ImageInfo *image_info,Image *image, assert(image != (Image *) NULL); assert(image->signature == MagickSignature); assert(exception != (ExceptionInfo *) NULL); - image->logging=IsEventLogging(); + image->logging=IsEventLogged(CoderEvent); clone_info=CloneImageInfo(image_info); if (clone_info) { @@ -2490,7 +2545,7 @@ MagickExport MagickPassFail WriteImagesFile(const ImageInfo *image_info,Image *i assert(image != (Image *) NULL); assert(image->signature == MagickSignature); assert(exception != (ExceptionInfo *) NULL); - image->logging=IsEventLogging(); + image->logging=IsEventLogged(CoderEvent); clone_info=CloneImageInfo(image_info); if (clone_info) { |