]> granicus.if.org Git - imagemagick/commitdiff
(no commit message)
authorcristy <urban-warrior@git.imagemagick.org>
Fri, 5 Apr 2013 15:59:08 +0000 (15:59 +0000)
committercristy <urban-warrior@git.imagemagick.org>
Fri, 5 Apr 2013 15:59:08 +0000 (15:59 +0000)
MagickCore/colorspace.c

index b9f237eed1e480c561e6046023426cb0ba461ce4..007d0dc1c882bdb7581244d303118f8f24501518 100644 (file)
@@ -2579,10 +2579,10 @@ static MagickBooleanType TransformsRGBImage(Image *image,
         return(MagickFalse);
       return(status);
     }
-    case LCHColorspace:
+    case LCHabColorspace:
     {
       /*
-        Transform image from LCH to sRGB.
+        Transform image from LCHab to sRGB.
       */
       if (image->storage_class == PseudoClass)
         {
@@ -2644,6 +2644,72 @@ static MagickBooleanType TransformsRGBImage(Image *image,
         return(MagickFalse);
       return(status);
     }
+    case LCHColorspace:
+    case LCHuvColorspace:
+    {
+      /*
+        Transform image from LCHuv to sRGB.
+      */
+      if (image->storage_class == PseudoClass)
+        {
+          if (SyncImage(image,exception) == MagickFalse)
+            return(MagickFalse);
+          if (SetImageStorageClass(image,DirectClass,exception) == MagickFalse)
+            return(MagickFalse);
+        }
+      image_view=AcquireAuthenticCacheView(image,exception);
+#if defined(MAGICKCORE_OPENMP_SUPPORT)
+      #pragma omp parallel for schedule(static,4) shared(status) \
+        magick_threads(image,image,image->rows,1)
+#endif
+      for (y=0; y < (ssize_t) image->rows; y++)
+      {
+        MagickBooleanType
+          sync;
+
+        register ssize_t
+          x;
+
+        register Quantum
+          *restrict q;
+
+        if (status == MagickFalse)
+          continue;
+        q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,
+          exception);
+        if (q == (Quantum *) NULL)
+          {
+            status=MagickFalse;
+            continue;
+          }
+        for (x=0; x < (ssize_t) image->columns; x++)
+        {
+          double
+            blue,
+            chroma,
+            green,
+            hue,
+            luma,
+            red;
+
+          luma=(double) (QuantumScale*GetPixelRed(image,q));
+          chroma=(double) (QuantumScale*GetPixelGreen(image,q));
+          hue=(double) (QuantumScale*GetPixelBlue(image,q));
+          ConvertLCHuvToRGB(luma,chroma,hue,&red,&green,&blue);
+          SetPixelRed(image,ClampToQuantum(EncodePixelGamma(red)),q);
+          SetPixelGreen(image,ClampToQuantum(EncodePixelGamma(green)),q);
+          SetPixelBlue(image,ClampToQuantum(EncodePixelGamma(blue)),q);
+          q+=GetPixelChannels(image);
+        }
+        sync=SyncCacheViewAuthenticPixels(image_view,exception);
+        if (sync == MagickFalse)
+          status=MagickFalse;
+      }
+      image_view=DestroyCacheView(image_view);
+      if (SetImageColorspace(image,sRGBColorspace,exception) == MagickFalse)
+        return(MagickFalse);
+      return(status);
+    }
     case LMSColorspace:
     {
       /*