]> granicus.if.org Git - imagemagick/blobdiff - coders/plasma.c
(no commit message)
[imagemagick] / coders / plasma.c
index 9d8e460e8e49e02fb68438f21752a0e53eca0d6c..92afd5a71f6a0e19e4ea3b9418f29dc0d7a8fe40 100644 (file)
@@ -17,7 +17,7 @@
 %                                 July 1992                                   %
 %                                                                             %
 %                                                                             %
-%  Copyright 1999-2010 ImageMagick Studio LLC, a non-profit organization      %
+%  Copyright 1999-2013 ImageMagick Studio LLC, a non-profit organization      %
 %  dedicated to making software imaging solutions freely available.           %
 %                                                                             %
 %  You may not use this file except in compliance with the License.  You may  %
 /*
   Include declarations.
 */
-#include "magick/studio.h"
-#include "magick/blob.h"
-#include "magick/blob-private.h"
-#include "magick/cache.h"
-#include "magick/constitute.h"
-#include "magick/exception.h"
-#include "magick/exception-private.h"
-#include "magick/fx.h"
-#include "magick/image.h"
-#include "magick/image-private.h"
-#include "magick/list.h"
-#include "magick/magick.h"
-#include "magick/memory_.h"
-#include "magick/monitor.h"
-#include "magick/monitor-private.h"
-#include "magick/random_.h"
-#include "magick/random-private.h"
-#include "magick/signature-private.h"
-#include "magick/quantum-private.h"
-#include "magick/static.h"
-#include "magick/string_.h"
-#include "magick/module.h"
+#include "MagickCore/studio.h"
+#include "MagickCore/blob.h"
+#include "MagickCore/blob-private.h"
+#include "MagickCore/cache.h"
+#include "MagickCore/channel.h"
+#include "MagickCore/constitute.h"
+#include "MagickCore/exception.h"
+#include "MagickCore/exception-private.h"
+#include "MagickCore/fx.h"
+#include "MagickCore/image.h"
+#include "MagickCore/image-private.h"
+#include "MagickCore/list.h"
+#include "MagickCore/magick.h"
+#include "MagickCore/memory_.h"
+#include "MagickCore/monitor.h"
+#include "MagickCore/monitor-private.h"
+#include "MagickCore/pixel-accessor.h"
+#include "MagickCore/random_.h"
+#include "MagickCore/random-private.h"
+#include "MagickCore/signature-private.h"
+#include "MagickCore/quantum-private.h"
+#include "MagickCore/static.h"
+#include "MagickCore/string_.h"
+#include "MagickCore/module.h"
 \f
 /*
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -97,29 +99,21 @@ static inline size_t MagickMax(const size_t x,const size_t y)
 }
 
 static inline void PlasmaPixel(Image *image,RandomInfo *random_info,double x,
-  double y)
+  double y,ExceptionInfo *exception)
 {
-  ExceptionInfo
-    *exception;
-
-  QuantumAny
-    range;
-
-  register PixelPacket
+  register Quantum
     *q;
 
-  exception=(&image->exception);
-  q=GetAuthenticPixels(image,(long) ceil(x-0.5),(long) ceil(y-0.5),1,1,
+  q=GetAuthenticPixels(image,(ssize_t) ceil(x-0.5),(ssize_t) ceil(y-0.5),1,1,
     exception);
-  if (q == (PixelPacket *) NULL)
+  if (q == (Quantum *) NULL)
     return;
-  range=GetQuantumRange(16UL);
-  q->red=ScaleAnyToQuantum((unsigned long) (65535.0*
-    GetPseudoRandomValue(random_info)+0.5),range);
-  q->green=ScaleAnyToQuantum((unsigned long) (65535.0*
-    GetPseudoRandomValue(random_info)+0.5),range);
-  q->blue=ScaleAnyToQuantum((unsigned long) (65535.0*
-    GetPseudoRandomValue(random_info)+0.5),range);
+  SetPixelRed(image,ScaleShortToQuantum((unsigned short) (65535.0*
+    GetPseudoRandomValue(random_info)+0.5)),q);
+  SetPixelGreen(image,ScaleShortToQuantum((unsigned short) (65535.0*
+    GetPseudoRandomValue(random_info)+0.5)),q);
+  SetPixelBlue(image,ScaleShortToQuantum((unsigned short) (65535.0*
+    GetPseudoRandomValue(random_info)+0.5)),q);
   (void) SyncAuthenticPixels(image,exception);
 }
 
@@ -132,49 +126,49 @@ static Image *ReadPlasmaImage(const ImageInfo *image_info,
   ImageInfo
     *read_info;
 
-  long
-    y;
-
   MagickBooleanType
     status;
 
-  register long
+  register ssize_t
     x;
 
-  register PixelPacket
+  register Quantum
     *q;
 
-  register unsigned long
+  register size_t
     i;
 
   SegmentInfo
     segment_info;
 
-  unsigned long
+  size_t
     depth,
     max_depth;
 
+  ssize_t
+    y;
+
   /*
     Recursively apply plasma to the image.
   */
   read_info=CloneImageInfo(image_info);
   SetImageInfoBlob(read_info,(void *) NULL,0);
-  (void) FormatMagickString(read_info->filename,MaxTextExtent,
+  (void) FormatLocaleString(read_info->filename,MaxTextExtent,
     "gradient:%s",image_info->filename);
   image=ReadImage(read_info,exception);
   read_info=DestroyImageInfo(read_info);
   if (image == (Image *) NULL)
     return((Image *) NULL);
-  image->storage_class=DirectClass;
-  for (y=0; y < (long) image->rows; y++)
+  (void) SetImageStorageClass(image,DirectClass,exception);
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     q=GetAuthenticPixels(image,0,y,image->columns,1,exception);
-    if (q == (PixelPacket *) NULL)
+    if (q == (Quantum *) NULL)
       break;
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
-      q->opacity=(Quantum) (QuantumRange/2);
-      q++;
+      SetPixelAlpha(image,QuantumRange/2,q);
+      q+=GetPixelChannels(image);
     }
     if (SyncAuthenticPixels(image,exception) == MagickFalse)
       break;
@@ -191,36 +185,37 @@ static Image *ReadPlasmaImage(const ImageInfo *image_info,
       /*
         Seed pixels before recursion.
       */
+      (void) SetImageColorspace(image,sRGBColorspace,exception);
       random_info=AcquireRandomInfo();
-      PlasmaPixel(image,random_info,segment_info.x1,segment_info.y1);
+      PlasmaPixel(image,random_info,segment_info.x1,segment_info.y1,exception);
       PlasmaPixel(image,random_info,segment_info.x1,(segment_info.y1+
-        segment_info.y2)/2);
-      PlasmaPixel(image,random_info,segment_info.x1,segment_info.y2);
+        segment_info.y2)/2,exception);
+      PlasmaPixel(image,random_info,segment_info.x1,segment_info.y2,exception);
       PlasmaPixel(image,random_info,(segment_info.x1+segment_info.x2)/2,
-        segment_info.y1);
+        segment_info.y1,exception);
       PlasmaPixel(image,random_info,(segment_info.x1+segment_info.x2)/2,
-        (segment_info.y1+segment_info.y2)/2);
+        (segment_info.y1+segment_info.y2)/2,exception);
       PlasmaPixel(image,random_info,(segment_info.x1+segment_info.x2)/2,
-        segment_info.y2);
-      PlasmaPixel(image,random_info,segment_info.x2,segment_info.y1);
+        segment_info.y2,exception);
+      PlasmaPixel(image,random_info,segment_info.x2,segment_info.y1,exception);
       PlasmaPixel(image,random_info,segment_info.x2,(segment_info.y1+
-        segment_info.y2)/2);
-      PlasmaPixel(image,random_info,segment_info.x2,segment_info.y2);
+        segment_info.y2)/2,exception);
+      PlasmaPixel(image,random_info,segment_info.x2,segment_info.y2,exception);
       random_info=DestroyRandomInfo(random_info);
     }
-  i=(unsigned long) MagickMax(image->columns,image->rows)/2;
+  i=(size_t) MagickMax(image->columns,image->rows)/2;
   for (max_depth=0; i != 0; max_depth++)
     i>>=1;
   for (depth=1; ; depth++)
   {
-    if (PlasmaImage(image,&segment_info,0,depth) != MagickFalse)
+    if (PlasmaImage(image,&segment_info,0,depth,exception) != MagickFalse)
       break;
     status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) depth,
       max_depth);
     if (status == MagickFalse)
       break;
   }
-  (void) SetImageAlphaChannel(image,DeactivateAlphaChannel);
+  (void) SetImageAlphaChannel(image,SetAlphaChannel,exception);
   return(GetFirstImageInList(image));
 }
 \f
@@ -244,10 +239,10 @@ static Image *ReadPlasmaImage(const ImageInfo *image_info,
 %
 %  The format of the RegisterPLASMAImage method is:
 %
-%      unsigned long RegisterPLASMAImage(void)
+%      size_t RegisterPLASMAImage(void)
 %
 */
-ModuleExport unsigned long RegisterPLASMAImage(void)
+ModuleExport size_t RegisterPLASMAImage(void)
 {
   MagickInfo
     *entry;
@@ -255,14 +250,14 @@ ModuleExport unsigned long RegisterPLASMAImage(void)
   entry=SetMagickInfo("PLASMA");
   entry->decoder=(DecodeImageHandler *) ReadPlasmaImage;
   entry->adjoin=MagickFalse;
-  entry->format_type=ExplicitFormatType;
+  entry->format_type=ImplicitFormatType;
   entry->description=ConstantString("Plasma fractal image");
   entry->module=ConstantString("PLASMA");
   (void) RegisterMagickInfo(entry);
   entry=SetMagickInfo("FRACTAL");
   entry->decoder=(DecodeImageHandler *) ReadPlasmaImage;
   entry->adjoin=MagickFalse;
-  entry->format_type=ExplicitFormatType;
+  entry->format_type=ImplicitFormatType;
   entry->description=ConstantString("Plasma fractal image");
   entry->module=ConstantString("PLASMA");
   (void) RegisterMagickInfo(entry);