]> granicus.if.org Git - imagemagick/blobdiff - coders/dps.c
(no commit message)
[imagemagick] / coders / dps.c
index 446cbe4c5a2a6325589fccb7d9ab803e0e68276e..1498ed8f875d6ea804a61207b1557e075da56d50 100644 (file)
@@ -17,7 +17,7 @@
 %                                 July 1992                                   %
 %                                                                             %
 %                                                                             %
-%  Copyright 1999-2010 ImageMagick Studio LLC, a non-profit organization      %
+%  Copyright 1999-2012 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/client.h"
-#include "magick/exception.h"
-#include "magick/exception-private.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/quantum-private.h"
-#include "magick/static.h"
-#include "magick/string_.h"
-#include "magick/module.h"
-#include "magick/utility.h"
-#include "magick/xwindow-private.h"
+#include "MagickCore/studio.h"
+#include "MagickCore/blob.h"
+#include "MagickCore/blob-private.h"
+#include "MagickCore/client.h"
+#include "MagickCore/colormap.h"
+#include "MagickCore/exception.h"
+#include "MagickCore/exception-private.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/quantum-private.h"
+#include "MagickCore/static.h"
+#include "MagickCore/string_.h"
+#include "MagickCore/module.h"
+#include "MagickCore/utility.h"
+#include "MagickCore/xwindow-private.h"
 #if defined(MAGICKCORE_DPS_DELEGATE)
 #include <DPS/dpsXclient.h>
 #include <DPS/dpsXpreview.h>
@@ -116,28 +118,25 @@ static Image *ReadDPSImage(const ImageInfo *image_info,ExceptionInfo *exception)
     sans,
     status;
 
-  long
-    x,
-    y;
-
   Pixmap
     pixmap;
 
-  register IndexPacket
-    *indexes;
-
-  register long
+  register ssize_t
     i;
 
-  register PixelPacket
+  register Quantum
     *q;
 
-  register unsigned long
+  register size_t
     pixel;
 
   Screen
     *screen;
 
+  ssize_t
+    x,
+    y;
+
   XColor
     *colors;
 
@@ -180,7 +179,7 @@ static Image *ReadDPSImage(const ImageInfo *image_info,ExceptionInfo *exception)
   /*
     Open image file.
   */
-  image=AcquireImage(image_info);
+  image=AcquireImage(image_info,exception);
   status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
   if (status == MagickFalse)
     return((Image *) NULL);
@@ -219,8 +218,8 @@ static Image *ReadDPSImage(const ImageInfo *image_info,ExceptionInfo *exception)
   */
   screen=ScreenOfDisplay(display,visual_info->screen);
   pixels_per_point=XDPSPixelsPerPoint(screen);
-  if ((image->x_resolution != 0.0) && (image->y_resolution != 0.0))
-    pixels_per_point=MagickMin(image->x_resolution,image->y_resolution)/
+  if ((image->resolution.x != 0.0) && (image->resolution.y != 0.0))
+    pixels_per_point=MagickMin(image->resolution.x,image->resolution.y)/
       DefaultResolution;
   status=XDPSCreatePixmapForEPSF((DPSContext) NULL,screen,
     GetBlobFileHandle(image),visual_info->depth,pixels_per_point,&pixmap,
@@ -275,12 +274,12 @@ static Image *ReadDPSImage(const ImageInfo *image_info,ExceptionInfo *exception)
   if ((visual_info->klass != DirectColor) && (visual_info->klass != TrueColor))
     for (i=0; i < visual_info->colormap_size; i++)
     {
-      colors[i].pixel=(unsigned long) i;
+      colors[i].pixel=(size_t) i;
       colors[i].pad=0;
     }
   else
     {
-      unsigned long
+      size_t
         blue,
         blue_bit,
         green,
@@ -319,8 +318,8 @@ static Image *ReadDPSImage(const ImageInfo *image_info,ExceptionInfo *exception)
   */
   if ((visual_info->klass != TrueColor) && (visual_info->klass != DirectColor))
     image->storage_class=PseudoClass;
-  image->columns=(unsigned long) dps_image->width;
-  image->rows=(unsigned long) dps_image->height;
+  image->columns=(size_t) dps_image->width;
+  image->rows=(size_t) dps_image->height;
   if (image_info->ping != MagickFalse)
     {
       (void) CloseBlob(image);
@@ -331,11 +330,11 @@ static Image *ReadDPSImage(const ImageInfo *image_info,ExceptionInfo *exception)
     case DirectClass:
     default:
     {
-      register unsigned long
+      register size_t
         color,
         index;
 
-      unsigned long
+      size_t
         blue_mask,
         blue_shift,
         green_mask,
@@ -372,21 +371,21 @@ static Image *ReadDPSImage(const ImageInfo *image_info,ExceptionInfo *exception)
       */
       if ((visual_info->colormap_size > 0) &&
           (visual_info->klass == DirectColor))
-        for (y=0; y < (long) image->rows; y++)
+        for (y=0; y < (ssize_t) image->rows; y++)
         {
           q=QueueAuthenticPixels(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++)
           {
             pixel=XGetPixel(dps_image,x,y);
             index=(pixel >> red_shift) & red_mask;
-            q->red=ScaleShortToQuantum(colors[index].red);
+            SetPixelRed(image,ScaleShortToQuantum(colors[index].red),q);
             index=(pixel >> green_shift) & green_mask;
-            q->green=ScaleShortToQuantum(colors[index].green);
+            SetPixelGreen(image,ScaleShortToQuantum(colors[index].green),q);
             index=(pixel >> blue_shift) & blue_mask;
-            q->blue=ScaleShortToQuantum(colors[index].blue);
-            q++;
+            SetPixelBlue(image,ScaleShortToQuantum(colors[index].blue),q);
+            q+=GetPixelChannels(image);
           }
           if (SyncAuthenticPixels(image,exception) == MagickFalse)
             break;
@@ -394,24 +393,24 @@ static Image *ReadDPSImage(const ImageInfo *image_info,ExceptionInfo *exception)
             break;
         }
       else
-        for (y=0; y < (long) image->rows; y++)
+        for (y=0; y < (ssize_t) image->rows; y++)
         {
           q=QueueAuthenticPixels(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++)
           {
             pixel=XGetPixel(dps_image,x,y);
             color=(pixel >> red_shift) & red_mask;
             color=(color*65535L)/red_mask;
-            q->red=ScaleShortToQuantum((unsigned short) color);
+            SetPixelRed(image,ScaleShortToQuantum((unsigned short) color),q);
             color=(pixel >> green_shift) & green_mask;
             color=(color*65535L)/green_mask;
-            q->green=ScaleShortToQuantum((unsigned short) color);
+            SetPixelGreen(image,ScaleShortToQuantum((unsigned short) color),q);
             color=(pixel >> blue_shift) & blue_mask;
             color=(color*65535L)/blue_mask;
-            q->blue=ScaleShortToQuantum((unsigned short) color);
-            q++;
+            SetPixelBlue(image,ScaleShortToQuantum((unsigned short) color),q);
+            q+=GetPixelChannels(image);
           }
           if (SyncAuthenticPixels(image,exception) == MagickFalse)
             break;
@@ -425,7 +424,7 @@ static Image *ReadDPSImage(const ImageInfo *image_info,ExceptionInfo *exception)
       /*
         Create colormap.
       */
-      if (AcquireImageColormap(image,(unsigned long) visual_info->colormap_size) == MagickFalse)
+      if (AcquireImageColormap(image,(size_t) visual_info->colormap_size,exception) == MagickFalse)
         {
           image=DestroyImage(image);
           colors=(XColor *) RelinquishMagickMemory(colors);
@@ -434,7 +433,7 @@ static Image *ReadDPSImage(const ImageInfo *image_info,ExceptionInfo *exception)
             (XFontStruct *) NULL,&resource_info,(XWindowInfo *) NULL);
           return((Image *) NULL);
         }
-      for (i=0; i < (long) image->colors; i++)
+      for (i=0; i < (ssize_t) image->colors; i++)
       {
         image->colormap[colors[i].pixel].red=ScaleShortToQuantum(colors[i].red);
         image->colormap[colors[i].pixel].green=
@@ -445,14 +444,16 @@ static Image *ReadDPSImage(const ImageInfo *image_info,ExceptionInfo *exception)
       /*
         Convert X image to PseudoClass packets.
       */
-      for (y=0; y < (long) image->rows; y++)
+      for (y=0; y < (ssize_t) image->rows; y++)
       {
         q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
-        if (q == (PixelPacket *) NULL)
+        if (q == (Quantum *) NULL)
           break;
-        indexes=GetAuthenticIndexQueue(image);
-        for (x=0; x < (long) image->columns; x++)
-          indexes[x]=(unsigned short) XGetPixel(dps_image,x,y);
+        for (x=0; x < (ssize_t) image->columns; x++)
+        {
+          SetPixelIndex(image,(unsigned short) XGetPixel(dps_image,x,y),q);
+          q+=GetPixelChannels(image);
+        }
         if (SyncAuthenticPixels(image,exception) == MagickFalse)
           break;
         if (SetImageProgress(image,LoadImageTag,y,image->rows) == MagickFalse)
@@ -464,7 +465,7 @@ static Image *ReadDPSImage(const ImageInfo *image_info,ExceptionInfo *exception)
   colors=(XColor *) RelinquishMagickMemory(colors);
   XDestroyImage(dps_image);
   if (image->storage_class == PseudoClass)
-    (void) SyncImage(image);
+    (void) SyncImage(image,exception);
   /*
     Rasterize matte image.
   */
@@ -490,17 +491,17 @@ static Image *ReadDPSImage(const ImageInfo *image_info,ExceptionInfo *exception)
             {
               image->storage_class=DirectClass;
               image->matte=MagickTrue;
-              for (y=0; y < (long) image->rows; y++)
+              for (y=0; y < (ssize_t) image->rows; y++)
               {
                 q=QueueAuthenticPixels(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++)
                 {
-                  SetOpacityPixelComponent(q,OpaqueOpacity);
+                  SetPixelAlpha(image,OpaqueAlpha,q);
                   if (XGetPixel(matte_image,x,y) == 0)
-                    q->opacity=TransparentOpacity;
-                  q++;
+                    SetPixelAlpha(image,TransparentAlpha,q);
+                  q+=GetPixelChannels(image);
                 }
                 if (SyncAuthenticPixels(image,exception) == MagickFalse)
                   break;
@@ -539,10 +540,10 @@ static Image *ReadDPSImage(const ImageInfo *image_info,ExceptionInfo *exception)
 %
 %  The format of the RegisterDPSImage method is:
 %
-%      unsigned long RegisterDPSImage(void)
+%      size_t RegisterDPSImage(void)
 %
 */
-ModuleExport unsigned long RegisterDPSImage(void)
+ModuleExport size_t RegisterDPSImage(void)
 {
   MagickInfo
     *entry;