]> granicus.if.org Git - imagemagick/commitdiff
(no commit message)
authorcristy <urban-warrior@git.imagemagick.org>
Fri, 22 Apr 2011 12:53:27 +0000 (12:53 +0000)
committercristy <urban-warrior@git.imagemagick.org>
Fri, 22 Apr 2011 12:53:27 +0000 (12:53 +0000)
ChangeLog
coders/fits.c

index 5668d5fce3b0a7670aa186969add7dd950893130..f6929359e341fd8e0677721c34b0485b18d1dd80 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -13,6 +13,7 @@
     text chunks.
   * Added "-define PNG:preserve-colormap" option (reference
     http://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=18564).
+  * Add support for writing RGB FITS images as separate planes.
 
 2011-04-16  6.6.9-6 Cristy  <quetzlzacatenango@image...>
   * Support the HDR 32-bit_rle_xyze format.
index fa569bfc99198dd325c453a2b1f8dda83d46940a..93a7d20f03d53ae51254896c72307c882fe84c4d 100644 (file)
@@ -661,7 +661,7 @@ static MagickBooleanType WriteFITSImage(const ImageInfo *image_info,
   (void) strncpy(fits_info+offset,header,strlen(header));
   offset+=80;
   (void) FormatMagickString(header,FITSBlocksize,"NAXIS   =           %10lu",
-    2UL);
+    IsGrayImage(image,&image->exception) != MagickFalse ? 2UL : 3UL);
   (void) strncpy(fits_info+offset,header,strlen(header));
   offset+=80;
   (void) FormatMagickString(header,FITSBlocksize,"NAXIS1  =           %10lu",
@@ -672,6 +672,13 @@ static MagickBooleanType WriteFITSImage(const ImageInfo *image_info,
     (unsigned long) image->rows);
   (void) strncpy(fits_info+offset,header,strlen(header));
   offset+=80;
+  if (IsGrayImage(image,&image->exception) == MagickFalse)
+    {
+      (void) FormatMagickString(header,FITSBlocksize,
+        "NAXIS3  =           %10lu",3UL);
+      (void) strncpy(fits_info+offset,header,strlen(header));
+      offset+=80;
+    }
   (void) FormatMagickString(header,FITSBlocksize,"BSCALE  =         %E",1.0);
   (void) strncpy(fits_info+offset,header,strlen(header));
   offset+=80;
@@ -704,27 +711,96 @@ static MagickBooleanType WriteFITSImage(const ImageInfo *image_info,
     Convert image to fits scale PseudoColor class.
   */
   pixels=GetQuantumPixels(quantum_info);
-  length=GetQuantumExtent(image,quantum_info,GrayQuantum);
-  for (y=(ssize_t) image->rows-1; y >= 0; y--)
-  {
-    p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
-    if (p == (const PixelPacket *) NULL)
-      break;
-    length=ExportQuantumPixels(image,(const CacheView *) NULL,quantum_info,
-      GrayQuantum,pixels,&image->exception);
-    if (image->depth == 16)
-      SetFITSUnsignedPixels(image->columns,image->depth,pixels);
-    if (((image->depth == 32) || (image->depth == 64)) &&
-        (quantum_info->format != FloatingPointQuantumFormat))
-      SetFITSUnsignedPixels(image->columns,image->depth,pixels);
-    count=WriteBlob(image,length,pixels);
-    if (count != (ssize_t) length)
-      break;
-    status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,
-      image->rows);
-    if (status == MagickFalse)
-      break;
-  }
+  if (IsGrayImage(image,&image->exception) != MagickFalse)
+    {
+      length=GetQuantumExtent(image,quantum_info,GrayQuantum);
+      for (y=(ssize_t) image->rows-1; y >= 0; y--)
+      {
+        p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
+        if (p == (const PixelPacket *) NULL)
+          break;
+        length=ExportQuantumPixels(image,(const CacheView *) NULL,quantum_info,
+          GrayQuantum,pixels,&image->exception);
+        if (image->depth == 16)
+          SetFITSUnsignedPixels(image->columns,image->depth,pixels);
+        if (((image->depth == 32) || (image->depth == 64)) &&
+            (quantum_info->format != FloatingPointQuantumFormat))
+          SetFITSUnsignedPixels(image->columns,image->depth,pixels);
+        count=WriteBlob(image,length,pixels);
+        if (count != (ssize_t) length)
+          break;
+        status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,
+          image->rows);
+        if (status == MagickFalse)
+          break;
+      }
+    }
+  else
+    {
+      length=GetQuantumExtent(image,quantum_info,RedQuantum);
+      for (y=(ssize_t) image->rows-1; y >= 0; y--)
+      {
+        p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
+        if (p == (const PixelPacket *) NULL)
+          break;
+        length=ExportQuantumPixels(image,(const CacheView *) NULL,quantum_info,
+          RedQuantum,pixels,&image->exception);
+        if (image->depth == 16)
+          SetFITSUnsignedPixels(image->columns,image->depth,pixels);
+        if (((image->depth == 32) || (image->depth == 64)) &&
+            (quantum_info->format != FloatingPointQuantumFormat))
+          SetFITSUnsignedPixels(image->columns,image->depth,pixels);
+        count=WriteBlob(image,length,pixels);
+        if (count != (ssize_t) length)
+          break;
+        status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,
+          image->rows);
+        if (status == MagickFalse)
+          break;
+      }
+      length=GetQuantumExtent(image,quantum_info,GreenQuantum);
+      for (y=(ssize_t) image->rows-1; y >= 0; y--)
+      {
+        p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
+        if (p == (const PixelPacket *) NULL)
+          break;
+        length=ExportQuantumPixels(image,(const CacheView *) NULL,quantum_info,
+          GreenQuantum,pixels,&image->exception);
+        if (image->depth == 16)
+          SetFITSUnsignedPixels(image->columns,image->depth,pixels);
+        if (((image->depth == 32) || (image->depth == 64)) &&
+            (quantum_info->format != FloatingPointQuantumFormat))
+          SetFITSUnsignedPixels(image->columns,image->depth,pixels);
+        count=WriteBlob(image,length,pixels);
+        if (count != (ssize_t) length)
+          break;
+        status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,
+          image->rows);
+        if (status == MagickFalse)
+          break;
+      }
+      length=GetQuantumExtent(image,quantum_info,BlueQuantum);
+      for (y=(ssize_t) image->rows-1; y >= 0; y--)
+      {
+        p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
+        if (p == (const PixelPacket *) NULL)
+          break;
+        length=ExportQuantumPixels(image,(const CacheView *) NULL,quantum_info,
+          BlueQuantum,pixels,&image->exception);
+        if (image->depth == 16)
+          SetFITSUnsignedPixels(image->columns,image->depth,pixels);
+        if (((image->depth == 32) || (image->depth == 64)) &&
+            (quantum_info->format != FloatingPointQuantumFormat))
+          SetFITSUnsignedPixels(image->columns,image->depth,pixels);
+        count=WriteBlob(image,length,pixels);
+        if (count != (ssize_t) length)
+          break;
+        status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,
+          image->rows);
+        if (status == MagickFalse)
+          break;
+      }
+    }
   quantum_info=DestroyQuantumInfo(quantum_info);
   length=(size_t) (FITSBlocksize-TellBlob(image) % FITSBlocksize);
   if (length != 0)