(no commit message)
authorcristy <urban-warrior@git.imagemagick.org>
Thu, 22 Nov 2012 16:56:12 +0000 (16:56 +0000)
committercristy <urban-warrior@git.imagemagick.org>
Thu, 22 Nov 2012 16:56:12 +0000 (16:56 +0000)
MagickCore/profile.c
MagickCore/property.c
MagickCore/quantum-export.c
MagickCore/quantum-import.c
MagickCore/quantum-private.h
coders/pnm.c

index ae5614f045511a978c1a4e21bd6095a6bfb1db1b..c78d85452f7d17654fbb6e3c9ede9d76cf91a79f 100644 (file)
@@ -1330,13 +1330,13 @@ static inline unsigned short ReadProfileShort(const EndianType endian,
   unsigned short
     value;
 
-  if (endian == MSBEndian)
+  if (endian == LSBEndian)
     {
-      value=(unsigned short) ((((unsigned char *) buffer)[0] << 8) |
-        ((unsigned char *) buffer)[1]);
+      value=(unsigned short) ((buffer[1] << 8) | buffer[0]);
       return((unsigned short) (value & 0xffff));
     }
-  value=(unsigned short) ((buffer[1] << 8) | buffer[0]);
+  value=(unsigned short) ((((unsigned char *) buffer)[0] << 8) |
+    ((unsigned char *) buffer)[1]);
   return((unsigned short) (value & 0xffff));
 }
 
@@ -1346,14 +1346,14 @@ static inline size_t ReadProfileLong(const EndianType endian,
   size_t
     value;
 
-  if (endian == MSBEndian)
+  if (endian == LSBEndian)
     {
-      value=(size_t) ((buffer[0] << 24) | (buffer[1] << 16) |
-        (buffer[2] << 8) | buffer[3]);
+      value=(size_t) ((buffer[3] << 24) | (buffer[2] << 16) |
+        (buffer[1] << 8 ) | (buffer[0]));
       return((size_t) (value & 0xffffffff));
     }
-  value=(size_t) ((buffer[3] << 24) | (buffer[2] << 16) |
-    (buffer[1] << 8 ) | (buffer[0]));
+  value=(size_t) ((buffer[0] << 24) | (buffer[1] << 16) |
+    (buffer[2] << 8) | buffer[3]);
   return((size_t) (value & 0xffffffff));
 }
 
@@ -1363,19 +1363,19 @@ static inline void WriteProfileLong(const EndianType endian,
   unsigned char
     buffer[4];
 
-  if (endian == MSBEndian)
+  if (endian == LSBEndian)
     {
-      buffer[0]=(unsigned char) (value >> 24);
-      buffer[1]=(unsigned char) (value >> 16);
-      buffer[2]=(unsigned char) (value >> 8);
-      buffer[3]=(unsigned char) value;
+      buffer[0]=(unsigned char) value;
+      buffer[1]=(unsigned char) (value >> 8);
+      buffer[2]=(unsigned char) (value >> 16);
+      buffer[3]=(unsigned char) (value >> 24);
       (void) CopyMagickMemory(p,buffer,4);
       return;
     }
-  buffer[0]=(unsigned char) value;
-  buffer[1]=(unsigned char) (value >> 8);
-  buffer[2]=(unsigned char) (value >> 16);
-  buffer[3]=(unsigned char) (value >> 24);
+  buffer[0]=(unsigned char) (value >> 24);
+  buffer[1]=(unsigned char) (value >> 16);
+  buffer[2]=(unsigned char) (value >> 8);
+  buffer[3]=(unsigned char) value;
   (void) CopyMagickMemory(p,buffer,4);
 }
 
@@ -1385,15 +1385,15 @@ static void WriteProfileShort(const EndianType endian,
   unsigned char
     buffer[2];
 
-  if (endian == MSBEndian)
+  if (endian == LSBEndian)
     {
-      buffer[0]=(unsigned char) (value >> 8);
-      buffer[1]=(unsigned char) value;
+      buffer[0]=(unsigned char) value;
+      buffer[1]=(unsigned char) (value >> 8);
       (void) CopyMagickMemory(p,buffer,2);
       return;
     }
-  buffer[0]=(unsigned char) value;
-  buffer[1]=(unsigned char) (value >> 8);
+  buffer[0]=(unsigned char) (value >> 8);
+  buffer[1]=(unsigned char) value;
   (void) CopyMagickMemory(p,buffer,2);
 }
 
index be1bfa3932329847d43ab6b3c51e2dae25460798..3c28537959799fa01fa90420436c9ed4053d6508 100644 (file)
@@ -700,13 +700,13 @@ static inline unsigned short ReadPropertyShort(const EndianType endian,
   unsigned short
     value;
 
-  if (endian == MSBEndian)
+  if (endian == LSBEndian)
     {
-      value=(unsigned short) ((((unsigned char *) buffer)[0] << 8) |
-        ((unsigned char *) buffer)[1]);
+      value=(unsigned short) ((buffer[1] << 8) | buffer[0]);
       return((unsigned short) (value & 0xffff));
     }
-  value=(unsigned short) ((buffer[1] << 8) | buffer[0]);
+  value=(unsigned short) ((((unsigned char *) buffer)[0] << 8) |
+    ((unsigned char *) buffer)[1]);
   return((unsigned short) (value & 0xffff));
 }
 
@@ -716,14 +716,14 @@ static inline size_t ReadPropertyLong(const EndianType endian,
   size_t
     value;
 
-  if (endian == MSBEndian)
+  if (endian == LSBEndian)
     {
-      value=(size_t) ((buffer[0] << 24) | (buffer[1] << 16) |
-        (buffer[2] << 8) | buffer[3]);
+      value=(size_t) ((buffer[3] << 24) | (buffer[2] << 16) |
+        (buffer[1] << 8 ) | (buffer[0]));
       return((size_t) (value & 0xffffffff));
     }
-  value=(size_t) ((buffer[3] << 24) | (buffer[2] << 16) |
-    (buffer[1] << 8 ) | (buffer[0]));
+  value=(size_t) ((buffer[0] << 24) | (buffer[1] << 16) |
+    (buffer[2] << 8) | buffer[3]);
   return((size_t) (value & 0xffffffff));
 }
 
index 404992c073210cf48a4c9c727c2058e8c7411a2a..4a209226537fecd468f0e378275164709463a4e0 100644 (file)
@@ -121,26 +121,26 @@ static inline unsigned char *PopDoublePixel(QuantumInfo *quantum_info,
 
   p=(double *) quantum;
   *p=(double) (pixel*quantum_info->state.inverse_scale+quantum_info->minimum);
-  if (quantum_info->endian == MSBEndian)
+  if (quantum_info->endian == LSBEndian)
     {
-      *pixels++=quantum[7];
-      *pixels++=quantum[6];
-      *pixels++=quantum[5];
-      *pixels++=quantum[4];
-      *pixels++=quantum[3];
-      *pixels++=quantum[2];
-      *pixels++=quantum[1];
       *pixels++=quantum[0];
+      *pixels++=quantum[1];
+      *pixels++=quantum[2];
+      *pixels++=quantum[3];
+      *pixels++=quantum[4];
+      *pixels++=quantum[5];
+      *pixels++=quantum[6];
+      *pixels++=quantum[7];
       return(pixels);
     }
-  *pixels++=quantum[0];
-  *pixels++=quantum[1];
-  *pixels++=quantum[2];
-  *pixels++=quantum[3];
-  *pixels++=quantum[4];
-  *pixels++=quantum[5];
-  *pixels++=quantum[6];
   *pixels++=quantum[7];
+  *pixels++=quantum[6];
+  *pixels++=quantum[5];
+  *pixels++=quantum[4];
+  *pixels++=quantum[3];
+  *pixels++=quantum[2];
+  *pixels++=quantum[1];
+  *pixels++=quantum[0];
   return(pixels);
 }
 
@@ -156,18 +156,18 @@ static inline unsigned char *PopFloatPixel(QuantumInfo *quantum_info,
   p=(float *) quantum;
   *p=(float) ((double) pixel*quantum_info->state.inverse_scale+
     quantum_info->minimum);
-  if (quantum_info->endian == MSBEndian)
+  if (quantum_info->endian == LSBEndian)
     {
-      *pixels++=quantum[3];
-      *pixels++=quantum[2];
-      *pixels++=quantum[1];
       *pixels++=quantum[0];
+      *pixels++=quantum[1];
+      *pixels++=quantum[2];
+      *pixels++=quantum[3];
       return(pixels);
     }
-  *pixels++=quantum[0];
-  *pixels++=quantum[1];
-  *pixels++=quantum[2];
   *pixels++=quantum[3];
+  *pixels++=quantum[2];
+  *pixels++=quantum[1];
+  *pixels++=quantum[0];
   return(pixels);
 }
 
index 0cfe8f33ed1d40248f3bf88addae4baff802d4a4..bf7d23ef448c317eae585646522ad2c22d14d294 100644 (file)
@@ -129,30 +129,34 @@ static inline const unsigned char *PushDoublePixel(QuantumInfo *quantum_info,
   unsigned char
     quantum[8];
 
-  if (quantum_info->endian == MSBEndian)
+  if (quantum_info->endian == LSBEndian)
     {
-      quantum[7]=(*pixels++);
-      quantum[6]=(*pixels++);
-      quantum[5]=(*pixels++);
-      quantum[5]=(*pixels++);
-      quantum[3]=(*pixels++);
-      quantum[2]=(*pixels++);
-      quantum[1]=(*pixels++);
+      p=(double *) quantum;
+      *pixel=(*p);
+      *pixel-=quantum_info->minimum;
+      *pixel*=quantum_info->scale;
       quantum[0]=(*pixels++);
+      quantum[1]=(*pixels++);
+      quantum[2]=(*pixels++);
+      quantum[3]=(*pixels++);
+      quantum[4]=(*pixels++);
+      quantum[5]=(*pixels++);
+      quantum[6]=(*pixels++);
+      quantum[7]=(*pixels++);
       p=(double *) quantum;
       *pixel=(*p);
       *pixel-=quantum_info->minimum;
       *pixel*=quantum_info->scale;
       return(pixels);
     }
-  quantum[0]=(*pixels++);
-  quantum[1]=(*pixels++);
-  quantum[2]=(*pixels++);
-  quantum[3]=(*pixels++);
-  quantum[4]=(*pixels++);
-  quantum[5]=(*pixels++);
-  quantum[6]=(*pixels++);
   quantum[7]=(*pixels++);
+  quantum[6]=(*pixels++);
+  quantum[5]=(*pixels++);
+  quantum[5]=(*pixels++);
+  quantum[3]=(*pixels++);
+  quantum[2]=(*pixels++);
+  quantum[1]=(*pixels++);
+  quantum[0]=(*pixels++);
   p=(double *) quantum;
   *pixel=(*p);
   *pixel-=quantum_info->minimum;
@@ -169,22 +173,22 @@ static inline const unsigned char *PushFloatPixel(QuantumInfo *quantum_info,
   unsigned char
     quantum[4];
 
-  if (quantum_info->endian == MSBEndian)
+  if (quantum_info->endian == LSBEndian)
     {
-      quantum[3]=(*pixels++);
-      quantum[2]=(*pixels++);
-      quantum[1]=(*pixels++);
       quantum[0]=(*pixels++);
+      quantum[1]=(*pixels++);
+      quantum[2]=(*pixels++);
+      quantum[3]=(*pixels++);
       p=(float *) quantum;
       *pixel=(*p);
       *pixel-=quantum_info->minimum;
       *pixel*=quantum_info->scale;
       return(pixels);
     }
-  quantum[0]=(*pixels++);
-  quantum[1]=(*pixels++);
-  quantum[2]=(*pixels++);
   quantum[3]=(*pixels++);
+  quantum[2]=(*pixels++);
+  quantum[1]=(*pixels++);
+  quantum[0]=(*pixels++);
   p=(float *) quantum;
   *pixel=(*p);
   *pixel-=quantum_info->minimum;
@@ -1685,18 +1689,18 @@ static void ImportGrayQuantum(const Image *image,QuantumInfo *quantum_info,
       range=GetQuantumRange(quantum_info->depth);
       if (quantum_info->pack == MagickFalse)
         {
-          if (image->endian == MSBEndian)
+          if (image->endian == LSBEndian)
             {
               for (x=0; x < (ssize_t) (number_pixels-2); x+=3)
               {
                 p=PushLongPixel(quantum_info->endian,p,&pixel);
-                SetPixelGray(image,ScaleAnyToQuantum((pixel >> 2) & 0x3ff,
+                SetPixelGray(image,ScaleAnyToQuantum((pixel >> 22) & 0x3ff,
                   range),q);
                 q+=GetPixelChannels(image);
                 SetPixelGray(image,ScaleAnyToQuantum((pixel >> 12) & 0x3ff,
                   range),q);
                 q+=GetPixelChannels(image);
-                SetPixelGray(image,ScaleAnyToQuantum((pixel >> 22) & 0x3ff,
+                SetPixelGray(image,ScaleAnyToQuantum((pixel >> 2) & 0x3ff,
                   range),q);
                 p+=quantum_info->pad;
                 q+=GetPixelChannels(image);
@@ -1704,7 +1708,7 @@ static void ImportGrayQuantum(const Image *image,QuantumInfo *quantum_info,
               p=PushLongPixel(quantum_info->endian,p,&pixel);
               if (x++ < (ssize_t) (number_pixels-1))
                 {
-                  SetPixelGray(image,ScaleAnyToQuantum((pixel >> 2) & 0x3ff,
+                  SetPixelGray(image,ScaleAnyToQuantum((pixel >> 22) & 0x3ff,
                     range),q);
                   q+=GetPixelChannels(image);
                 }
@@ -1719,13 +1723,13 @@ static void ImportGrayQuantum(const Image *image,QuantumInfo *quantum_info,
           for (x=0; x < (ssize_t) (number_pixels-2); x+=3)
           {
             p=PushLongPixel(quantum_info->endian,p,&pixel);
-            SetPixelGray(image,ScaleAnyToQuantum((pixel >> 22) & 0x3ff,range),
+            SetPixelGray(image,ScaleAnyToQuantum((pixel >> 2) & 0x3ff,range),
               q);
             q+=GetPixelChannels(image);
             SetPixelGray(image,ScaleAnyToQuantum((pixel >> 12) & 0x3ff,range),
               q);
             q+=GetPixelChannels(image);
-            SetPixelGray(image,ScaleAnyToQuantum((pixel >> 2) & 0x3ff,range),
+            SetPixelGray(image,ScaleAnyToQuantum((pixel >> 22) & 0x3ff,range),
               q);
             p+=quantum_info->pad;
             q+=GetPixelChannels(image);
@@ -1733,14 +1737,14 @@ static void ImportGrayQuantum(const Image *image,QuantumInfo *quantum_info,
           p=PushLongPixel(quantum_info->endian,p,&pixel);
           if (x++ < (ssize_t) (number_pixels-1))
             {
-              SetPixelGray(image,ScaleAnyToQuantum((pixel >> 22) & 0x3ff,range),
-                q);
+              SetPixelGray(image,ScaleAnyToQuantum((pixel >> 2) & 0x3ff,
+                range),q);
               q+=GetPixelChannels(image);
             }
           if (x++ < (ssize_t) number_pixels)
             {
-              SetPixelGray(image,ScaleAnyToQuantum((pixel >> 12) & 0x3ff,range),
-                q);
+              SetPixelGray(image,ScaleAnyToQuantum((pixel >> 12) & 0x3ff,
+                range),q);
               q+=GetPixelChannels(image);
             }
           break;
index 10f0f9e6c16cc5d2ca6b921b3ccf42468fee706c..3ea3068c92c1d6542742dc05fca431e753134484 100644 (file)
@@ -186,18 +186,18 @@ static inline unsigned char *PopLongPixel(const EndianType endian,
     quantum;
 
   quantum=(unsigned int) pixel;
-  if (endian == MSBEndian)
+  if (endian == LSBEndian)
     {
-      *pixels++=(unsigned char) (quantum >> 24);
-      *pixels++=(unsigned char) (quantum >> 16);
-      *pixels++=(unsigned char) (quantum >> 8);
       *pixels++=(unsigned char) (quantum);
+      *pixels++=(unsigned char) (quantum >> 8);
+      *pixels++=(unsigned char) (quantum >> 16);
+      *pixels++=(unsigned char) (quantum >> 24);
       return(pixels);
     }
-  *pixels++=(unsigned char) (quantum);
-  *pixels++=(unsigned char) (quantum >> 8);
-  *pixels++=(unsigned char) (quantum >> 16);
   *pixels++=(unsigned char) (quantum >> 24);
+  *pixels++=(unsigned char) (quantum >> 16);
+  *pixels++=(unsigned char) (quantum >> 8);
+  *pixels++=(unsigned char) (quantum);
   return(pixels);
 }
 
@@ -208,14 +208,14 @@ static inline unsigned char *PopShortPixel(const EndianType endian,
     quantum;
 
   quantum=pixel;
-  if (endian == MSBEndian)
+  if (endian == LSBEndian)
     {
-      *pixels++=(unsigned char) (quantum >> 8);
       *pixels++=(unsigned char) (quantum);
+      *pixels++=(unsigned char) (quantum >> 8);
       return(pixels);
     }
-  *pixels++=(unsigned char) (quantum);
   *pixels++=(unsigned char) (quantum >> 8);
+  *pixels++=(unsigned char) (quantum);
   return(pixels);
 }
 
@@ -232,19 +232,19 @@ static inline const unsigned char *PushLongPixel(const EndianType endian,
   register unsigned int
     quantum;
 
-  if (endian == MSBEndian)
+  if (endian == LSBEndian)
     {
-      quantum=(unsigned int) (*pixels++ << 24);
-      quantum|=(unsigned int) (*pixels++ << 16);
+      quantum=(unsigned int) (*pixels++);
       quantum|=(unsigned int) (*pixels++ << 8);
-      quantum|=(unsigned int) (*pixels++);
+      quantum|=(unsigned int) (*pixels++ << 16);
+      quantum|=(unsigned int) (*pixels++ << 24);
       *pixel=(unsigned int) (quantum & 0xffffffff);
       return(pixels);
     }
-  quantum=(unsigned int) (*pixels++);
-  quantum|=(unsigned int) (*pixels++ << 8);
+  quantum=(unsigned int) (*pixels++ << 24);
   quantum|=(unsigned int) (*pixels++ << 16);
-  quantum|=(unsigned int) (*pixels++ << 24);
+  quantum|=(unsigned int) (*pixels++ << 8);
+  quantum|=(unsigned int) (*pixels++);
   *pixel=(unsigned int) (quantum & 0xffffffff);
   return(pixels);
 }
@@ -255,15 +255,15 @@ static inline const unsigned char *PushShortPixel(const EndianType endian,
   register unsigned int
     quantum;
 
-  if (endian == MSBEndian)
+  if (endian == LSBEndian)
     {
-      quantum=(unsigned int) (*pixels++ << 8);
-      quantum|=(unsigned int) *pixels++;
+      quantum=(unsigned int) *pixels++;
+      quantum|=(unsigned int) (*pixels++ << 8);
       *pixel=(unsigned short) (quantum & 0xffff);
       return(pixels);
     }
-  quantum=(unsigned int) *pixels++;
-  quantum|=(unsigned int) (*pixels++ << 8);
+  quantum=(unsigned int) (*pixels++ << 8);
+  quantum|=(unsigned int) *pixels++;
   *pixel=(unsigned short) (quantum & 0xffff);
   return(pixels);
 }
index d778d7ad16384ff32663eef378b72f082b0702e9..f9a079adcc52d6560bbc236a5fff594622328bdd 100644 (file)
@@ -2139,8 +2139,8 @@ static MagickBooleanType WritePNMImage(const ImageInfo *image_info,Image *image,
       case 'F':
       case 'f':
       {
-        (void) WriteBlobString(image,image->endian == MSBEndian ? "1.0\n" :
-          "-1.0\n");
+        (void) WriteBlobString(image,image->endian == LSBEndian ? "-1.0\n" :
+          "1.0\n");
         image->depth=32;
         quantum_type=format == 'f' ? GrayQuantum : RGBQuantum;
         quantum_info=AcquireQuantumInfo((const ImageInfo *) NULL,image);