]> granicus.if.org Git - imagemagick/commitdiff
Accomodate max-pixel-channels
authorCristy <urban-warrior@imagemagick.org>
Wed, 9 Aug 2017 18:36:08 +0000 (14:36 -0400)
committerCristy <urban-warrior@imagemagick.org>
Wed, 9 Aug 2017 18:36:08 +0000 (14:36 -0400)
MagickCore/enhance.c
MagickCore/resize.c

index dba7880553faeb0fdc57e7d82e52d9eea68c7ed6..9a4a76d86e1db292ba00c38fa3bd6476b25ce17b 100644 (file)
@@ -1048,16 +1048,14 @@ MagickExport MagickBooleanType ContrastStretchImage(Image *image,
   assert(image->signature == MagickCoreSignature);
   if (image->debug != MagickFalse)
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
-  if (SyncImagePixelCache(image,exception) == MagickFalse)
-    return(MagickFalse);
   if (SetImageGray(image,exception) != MagickFalse)
     (void) SetImageColorspace(image,GRAYColorspace,exception);
-  black=(double *) AcquireQuantumMemory(GetPixelChannels(image),sizeof(*black));
-  white=(double *) AcquireQuantumMemory(GetPixelChannels(image),sizeof(*white));
-  histogram=(double *) AcquireQuantumMemory(MaxMap+1UL,GetPixelChannels(image)*
+  black=(double *) AcquireQuantumMemory(MaxPixelChannels,sizeof(*black));
+  white=(double *) AcquireQuantumMemory(MaxPixelChannels,sizeof(*white));
+  histogram=(double *) AcquireQuantumMemory(MaxMap+1UL,MaxPixelChannels*
     sizeof(*histogram));
-  stretch_map=(double *) AcquireQuantumMemory(MaxMap+1UL,
-    GetPixelChannels(image)*sizeof(*stretch_map));
+  stretch_map=(double *) AcquireQuantumMemory(MaxMap+1UL,MaxPixelChannels*
+    sizeof(*stretch_map));
   if ((black == (double *) NULL) || (white == (double *) NULL) ||
       (histogram == (double *) NULL) || (stretch_map == (double *) NULL))
     {
@@ -1533,20 +1531,17 @@ MagickExport MagickBooleanType EqualizeImage(Image *image,
   */
   assert(image != (Image *) NULL);
   assert(image->signature == MagickCoreSignature);
-  if (SyncImagePixelCache(image,exception) == MagickFalse)
-    return(MagickFalse);
 #if defined(MAGICKCORE_OPENCL_SUPPORT)
   if (AccelerateEqualizeImage(image,exception) != MagickFalse)
     return(MagickTrue);
 #endif
   if (image->debug != MagickFalse)
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
-  equalize_map=(double *) AcquireQuantumMemory(MaxMap+1UL,
-    GetPixelChannels(image)*sizeof(*equalize_map));
-  histogram=(double *) AcquireQuantumMemory(MaxMap+1UL,GetPixelChannels(image)*
+  equalize_map=(double *) AcquireQuantumMemory(MaxMap+1UL,MaxPixelChannels*
+    sizeof(*equalize_map));
+  histogram=(double *) AcquireQuantumMemory(MaxMap+1UL,MaxPixelChannels*
     sizeof(*histogram));
-  map=(double *) AcquireQuantumMemory(MaxMap+1UL,GetPixelChannels(image)*
-    sizeof(*map));
+  map=(double *) AcquireQuantumMemory(MaxMap+1UL,MaxPixelChannels*sizeof(*map));
   if ((equalize_map == (double *) NULL) || (histogram == (double *) NULL) ||
       (map == (double *) NULL))
     {
index fdd34619d922f4036842316f0d2c11c9a138d764..640e528746e267cbcbc3b45c200c01870d560562 100644 (file)
@@ -1879,8 +1879,8 @@ MagickExport Image *LiquidRescaleImage(const Image *image,const size_t columns,
     return(CloneImage(image,0,0,MagickTrue,exception));
   if ((columns <= 2) || (rows <= 2))
     return(ResizeImage(image,columns,rows,image->filter,exception));
-  pixel_info=AcquireVirtualMemory(image->columns,image->rows*
-    GetPixelChannels(image)*sizeof(*pixels));
+  pixel_info=AcquireVirtualMemory(image->columns,image->rows*MacPixelChannels*
+    sizeof(*pixels));
   if (pixel_info == (MemoryInfo *) NULL)
     return((Image *) NULL);
   pixels=(gfloat *) GetVirtualMemoryBlob(pixel_info);
@@ -3233,19 +3233,17 @@ MagickExport Image *ScaleImage(const Image *image,const size_t columns,
     Allocate memory.
   */
   x_vector=(double *) AcquireQuantumMemory((size_t) image->columns,
-    GetPixelChannels(image)*sizeof(*x_vector));
+    MaxPixelChannels*sizeof(*x_vector));
   scanline=x_vector;
   if (image->rows != scale_image->rows)
     scanline=(double *) AcquireQuantumMemory((size_t) image->columns,
-      GetPixelChannels(image)*sizeof(*scanline));
-  scale_scanline=(double *) AcquireQuantumMemory((size_t)
-    scale_image->columns,GetPixelChannels(image)*sizeof(*scale_scanline));
+      MaxPixelChannels*sizeof(*scanline));
+  scale_scanline=(double *) AcquireQuantumMemory((size_t) scale_image->columns,
+    MaxPixelChannels*sizeof(*scale_scanline));
   y_vector=(double *) AcquireQuantumMemory((size_t) image->columns,
-    GetPixelChannels(image)*sizeof(*y_vector));
-  if ((scanline == (double *) NULL) ||
-      (scale_scanline == (double *) NULL) ||
-      (x_vector == (double *) NULL) ||
-      (y_vector == (double *) NULL))
+    MaxPixelChannels*sizeof(*y_vector));
+  if ((scanline == (double *) NULL) || (scale_scanline == (double *) NULL) ||
+      (x_vector == (double *) NULL) || (y_vector == (double *) NULL))
     {
       scale_image=DestroyImage(scale_image);
       ThrowImageException(ResourceLimitError,"MemoryAllocationFailed");
@@ -3257,8 +3255,8 @@ MagickExport Image *ScaleImage(const Image *image,const size_t columns,
   next_row=MagickTrue;
   span.y=1.0;
   scale.y=(double) scale_image->rows/(double) image->rows;
-  (void) ResetMagickMemory(y_vector,0,(size_t) GetPixelChannels(image)*
-    image->columns*sizeof(*y_vector));
+  (void) ResetMagickMemory(y_vector,0,(size_t) MaxPixelChannels*image->columns*
+    sizeof(*y_vector));
   n=0;
   status=MagickTrue;
   image_view=AcquireVirtualCacheView(image,exception);