Sophie

Sophie

distrib > Mandriva > 10.0-com > i586 > by-pkgid > 4bbc951ffb522b33781b5ef4161ef4de > files > 9

ImageMagick-5.5.7.15-6.3.100mdk.src.rpm

--- ImageMagick-5.5.6/coders/psd.c.quantum	2005-03-16 08:45:41.497876000 -0500
+++ ImageMagick-5.5.6/coders/psd.c	2005-03-16 08:45:48.253115000 -0500
@@ -130,7 +130,7 @@
       {
         if (count == -128)
           continue;
-        pixel=ReadBlobByte(image);
+        pixel=ScaleCharToQuantum(ReadBlobByte(image));
         for (count=(-count+1); count > 0; count--)
         {
           q=GetImagePixels(image,(long) (x % image->columns),
@@ -142,44 +142,43 @@
           {
             case -1:
             {
-              if (image->colorspace == CMYKColorspace)
-                indexes[0]=(Quantum) (MaxRGB-ScaleCharToQuantum(pixel));
-        else
-        q->opacity=(Quantum) (MaxRGB-ScaleCharToQuantum(pixel));
+              q->opacity=(Quantum) (MaxRGB-pixel);
               break;
             }
             case 0:
             {
-              q->red=ScaleCharToQuantum(pixel);
+              q->red=(Quantum) pixel;
               if (image->storage_class == PseudoClass)
                 {
-                  indexes[0]=(IndexPacket) pixel;
-                  *q=image->colormap[pixel];
+                  *indexes=(IndexPacket) ScaleQuantumToChar(pixel);
+                  *q=image->colormap[*indexes];
                 }
               break;
             }
             case 1:
             {
               if (image->storage_class == PseudoClass)
-                q->opacity=ScaleCharToQuantum(pixel);
+                q->opacity=(Quantum) (MaxRGB-pixel);
               else
-                q->green=ScaleCharToQuantum(pixel);
+                q->green=(Quantum) pixel;
               break;
             }
             case 2:
             {
-              q->blue=ScaleCharToQuantum(pixel);
+              q->blue=(Quantum) pixel;
               break;
             }
             case 3:
             {
-              q->opacity=ScaleCharToQuantum(pixel);
+              if (image->colorspace == CMYKColorspace)
+                *indexes=(Quantum) pixel;
+              else
+                q->opacity=(Quantum) (MaxRGB-pixel);
               break;
             }
             case 4:
             {
-              if (image->colorspace == CMYKColorspace)
-                indexes[0]=(Quantum) (MaxRGB-ScaleCharToQuantum(pixel));
+              q->opacity=(Quantum) (MaxRGB-pixel);
               break;
             }
             default:
@@ -193,9 +192,9 @@
         continue;
       }
     count++;
-    for (i=count; i > 0; i--)
+    for (i=(long) count; i > 0; i--)
     {
-      pixel=ReadBlobByte(image);
+      pixel=ScaleCharToQuantum(ReadBlobByte(image));
       q=GetImagePixels(image,(long) (x % image->columns),
         (long) (x/image->columns),1,1);
       if (q == (PixelPacket *) NULL)
@@ -205,44 +204,43 @@
       {
         case -1:
         {
-          if (image->colorspace == CMYKColorspace)
-            indexes[0]=(Quantum) (MaxRGB-ScaleCharToQuantum(pixel));
-      else
-      q->opacity=(Quantum) (MaxRGB-ScaleCharToQuantum(pixel));
+          q->opacity=(Quantum) (MaxRGB-pixel);
           break;
         }
         case 0:
         {
-          q->red=ScaleCharToQuantum(pixel);
+          q->red=(Quantum) pixel;
           if (image->storage_class == PseudoClass)
             {
-              indexes[0]=(IndexPacket) pixel;
-              *q=image->colormap[pixel];
+              *indexes=(IndexPacket) ScaleQuantumToChar(pixel);
+              *q=image->colormap[*indexes];
             }
           break;
         }
         case 1:
         {
           if (image->storage_class == PseudoClass)
-            q->opacity=ScaleCharToQuantum(pixel);
+            q->opacity=(Quantum) (MaxRGB-pixel);
           else
-            q->green=ScaleCharToQuantum(pixel);
+            q->green=(Quantum) pixel;
           break;
         }
         case 2:
         {
-          q->blue=ScaleCharToQuantum(pixel);
+          q->blue=(Quantum) pixel;
           break;
         }
         case 3:
         {
-          q->opacity=ScaleCharToQuantum(pixel);
+          if (image->colorspace == CMYKColorspace)
+            *indexes=(Quantum) pixel;
+          else
+            q->opacity=(Quantum) (MaxRGB-pixel);
           break;
         }
         case 4:
         {
-          if (image->colorspace == CMYKColorspace)
-                indexes[0]=(Quantum) (MaxRGB-ScaleCharToQuantum(pixel));
+          q->opacity=(Quantum) (MaxRGB-pixel);
           break;
         }
         default:
@@ -1112,16 +1110,14 @@
             for (x=0; x < (long) layer_info[i].image->columns; x++)
             {
               if (packet_size == 1)
-                pixel=ScaleCharToQuantum(ReadBlobByte(layer_info[i].image));
+                    pixel=ScaleCharToQuantum(ReadBlobByte(layer_info[i].image));
               else
-                pixel=ScaleQuantumToShort(ReadBlobMSBShort(layer_info[i].image));
+                    pixel=ScaleShortToQuantum(ReadBlobMSBShort(
+                      layer_info[i].image));
               switch (layer_info[i].channel_info[j].type)
               {
                 case -1:  /* transparency mask */
                 {
-                   if (image->colorspace == CMYKColorspace)
-                     indexes[x]=(Quantum) (MaxRGB-pixel);
-           else
            q->opacity=(Quantum) (MaxRGB-pixel);
                   break;
                 }
@@ -1130,7 +1126,10 @@
                   q->red=(Quantum) pixel;
                   if (layer_info[i].image->storage_class == PseudoClass)
                     {
-                      indexes[x]=(IndexPacket) MaxRGB - ScaleQuantumToChar(pixel);
+                          if (packet_size == 1)
+                            indexes[x]=(IndexPacket) ScaleQuantumToChar(pixel);
+                          else
+                            indexes[x]=(IndexPacket) ScaleQuantumToShort(pixel);
                       *q=layer_info[i].image->colormap[indexes[x]];
                     }
                   break;
@@ -1138,7 +1137,7 @@
                 case 1:  /* second component (Green, Magenta, or opacity) */
                 {
                   if (layer_info[i].image->storage_class == PseudoClass)
-                    q->opacity=(Quantum) pixel;
+                        q->opacity=(Quantum) (MaxRGB-pixel);
                   else
                     q->green=(Quantum) pixel;
                   break;
@@ -1150,13 +1149,15 @@
                 }
                 case 3:  /* fourth component (Opacity or Black) */
                 {
-                  q->opacity=(Quantum) pixel;
+                      if (image->colorspace == CMYKColorspace)
+                        indexes[x]=(Quantum) pixel;
+                      else
+                        q->opacity=(Quantum) (MaxRGB-pixel);
                   break;
                 }
                 case 4:  /* fifth component (opacity) */
                 {
-                  if (image->colorspace == CMYKColorspace)
-                    indexes[x]=(Quantum) (MaxRGB-pixel);
+                      q->opacity=(Quantum) (MaxRGB-pixel);
                   break;
                 }
                 default:
@@ -1182,11 +1183,8 @@
               indexes=GetIndexes(layer_info[i].image);
               for (x=0; x < (long) layer_info[i].image->columns; x++)
               {
-                q->opacity=(Quantum) ((unsigned long)
+                    q->opacity=MaxRGB-(Quantum) ((unsigned long)
                   (q->opacity*layer_info[i].opacity)/MaxRGB);
-                if (layer_info[i].image->colorspace == CMYKColorspace)
-                  indexes[x]=(IndexPacket) ((unsigned long)
-                    (indexes[x]*layer_info[i].opacity)/MaxRGB);
                 q++;
               }
               if (!SyncImagePixels(layer_info[i].image))
@@ -1322,7 +1320,10 @@
                 q->red=(Quantum) pixel;
                 if (image->storage_class == PseudoClass)
                   {
+                    if (packet_size == 1)
                     indexes[x]=(IndexPacket) ScaleQuantumToChar(pixel);
+                    else
+                      indexes[x]=(IndexPacket) ScaleQuantumToShort(pixel);
                     *q=image->colormap[indexes[x]];
                   }
                 break;
@@ -1330,7 +1331,7 @@
               case 1:
               {
                 if (image->storage_class == PseudoClass)
-                  q->opacity=(Quantum) pixel;
+                  q->opacity=(Quantum) (MaxRGB-pixel);
                 else
                   q->green=(Quantum) pixel;
                 break;
@@ -1342,13 +1343,15 @@
               }
               case 3:
               {
-                q->opacity=(Quantum) pixel;
+                if (image->colorspace == CMYKColorspace)
+                  indexes[x]=(IndexPacket) pixel;
+                else
+                  q->opacity=(Quantum) (MaxRGB-pixel);
                 break;
               }
               case 4:
               {
-                if (image->colorspace == CMYKColorspace)
-                  indexes[x]=(IndexPacket) pixel;
+                q->opacity=(Quantum) (MaxRGB-pixel);
                 break;
               }
               default:
@@ -1371,12 +1374,13 @@
         q=GetImagePixels(image,0,y,image->columns,1);
         if (q == (PixelPacket *) NULL)
           break;
+        indexes=GetIndexes(image);
         for (x=0; x < (long) image->columns; x++)
         {
           q->red=(Quantum) (MaxRGB-q->red);
           q->green=(Quantum) (MaxRGB-q->green);
           q->blue=(Quantum) (MaxRGB-q->blue);
-          q->opacity=(Quantum) (MaxRGB-q->opacity);
+          indexes[x]=(IndexPacket) (MaxRGB-indexes[x]);
           q++;
         }
         if (!SyncImagePixels(image))