% Read/Write Flexible Image Transport System Images. %
% %
% Software Design %
-% John Cristy %
+% Cristy %
% July 1992 %
% %
% %
-% Copyright 1999-2013 ImageMagick Studio LLC, a non-profit organization %
+% Copyright 1999-2017 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 %
case 4:
{
if (bits_per_pixel > 0)
- return((double) ((int) ReadBlobLong(image)));
+ return((double) ReadBlobSignedLong(image));
return((double) ReadBlobFloat(image));
}
case 8:
return(ReadBlobDouble(image));
}
-static void GetFITSPixelExtrema(Image *image,const int bits_per_pixel,
- double *minima,double *maxima)
+static MagickOffsetType GetFITSPixelExtrema(Image *image,
+ const int bits_per_pixel,double *minima,double *maxima)
{
double
pixel;
i;
offset=TellBlob(image);
+ if (offset == -1)
+ return(-1);
number_pixels=(MagickSizeType) image->columns*image->rows;
*minima=GetFITSPixel(image,bits_per_pixel);
*maxima=(*minima);
if (pixel > *maxima)
*maxima=pixel;
}
- (void) SeekBlob(image,offset,SEEK_SET);
+ return(SeekBlob(image,offset,SEEK_SET));
}
static inline double GetFITSPixelRange(const size_t depth)
char
*comment,
keyword[9],
- property[MaxTextExtent],
+ property[MagickPathExtent],
value[73];
double
Open image file.
*/
assert(image_info != (const ImageInfo *) NULL);
- assert(image_info->signature == MagickSignature);
+ assert(image_info->signature == MagickCoreSignature);
if (image_info->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
image_info->filename);
assert(exception != (ExceptionInfo *) NULL);
- assert(exception->signature == MagickSignature);
+ assert(exception->signature == MagickCoreSignature);
image=AcquireImage(image_info,exception);
status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
if (status == MagickFalse)
fits_info.bits_per_pixel=8;
fits_info.columns=1;
fits_info.rows=1;
- fits_info.rows=1;
fits_info.number_planes=1;
fits_info.min_data=0.0;
fits_info.max_data=0.0;
}
keyword[i]='\0';
count=ReadBlob(image,72,(unsigned char *) value);
+ value[72]='\0';
if (count != 72)
break;
- value[72]='\0';
p=value;
if (*p == '=')
{
else
fits_info.endian=LSBEndian;
}
- (void) FormatLocaleString(property,MaxTextExtent,"fits:%s",keyword);
+ (void) FormatLocaleString(property,MagickPathExtent,"fits:%s",keyword);
(void) SetImageProperty(image,property,p,exception);
}
c=0;
c=ReadBlobByte(image);
if (fits_info.extend == MagickFalse)
break;
+ if ((fits_info.bits_per_pixel != 8) && (fits_info.bits_per_pixel != 16) &&
+ (fits_info.bits_per_pixel != 32) && (fits_info.bits_per_pixel != 64) &&
+ (fits_info.bits_per_pixel != -32) && (fits_info.bits_per_pixel != -64))
+ ThrowReaderException(CorruptImageError,"ImproperImageHeader");
number_pixels=(MagickSizeType) fits_info.columns*fits_info.rows;
if ((fits_info.simple != MagickFalse) && (fits_info.number_axes >= 1) &&
(fits_info.number_axes <= 4) && (number_pixels != 0))
if ((image_info->ping != MagickFalse) && (image_info->number_scenes != 0))
if (image->scene >= (image_info->scene+image_info->number_scenes-1))
break;
+ status=SetImageExtent(image,image->columns,image->rows,exception);
+ if (status == MagickFalse)
+ return(DestroyImageList(image));
/*
Initialize image structure.
*/
(void) SetImageColorspace(image,GRAYColorspace,exception);
if ((fits_info.min_data == 0.0) && (fits_info.max_data == 0.0))
{
- if ((fits_info.bits_per_pixel == -32) || (fits_info.max_data == -64))
- GetFITSPixelExtrema(image,fits_info.bits_per_pixel,
+ if ((fits_info.bits_per_pixel == -32) ||
+ (fits_info.bits_per_pixel == -64))
+ (void) GetFITSPixelExtrema(image,fits_info.bits_per_pixel,
&fits_info.min_data,&fits_info.max_data);
else
fits_info.max_data=GetFITSPixelRange((size_t)
MagickInfo
*entry;
- entry=SetMagickInfo("FITS");
+ entry=AcquireMagickInfo("FITS","FITS","Flexible Image Transport System");
entry->decoder=(DecodeImageHandler *) ReadFITSImage;
entry->encoder=(EncodeImageHandler *) WriteFITSImage;
entry->magick=(IsImageFormatHandler *) IsFITS;
- entry->adjoin=MagickFalse;
- entry->seekable_stream=MagickTrue;
- entry->description=ConstantString("Flexible Image Transport System");
- entry->module=ConstantString("FITS");
+ entry->flags^=CoderAdjoinFlag;
+ entry->flags|=CoderDecoderSeekableStreamFlag;
(void) RegisterMagickInfo(entry);
- entry=SetMagickInfo("FTS");
+ entry=AcquireMagickInfo("FITS","FTS","Flexible Image Transport System");
entry->decoder=(DecodeImageHandler *) ReadFITSImage;
entry->encoder=(EncodeImageHandler *) WriteFITSImage;
entry->magick=(IsImageFormatHandler *) IsFITS;
- entry->adjoin=MagickFalse;
- entry->seekable_stream=MagickTrue;
- entry->description=ConstantString("Flexible Image Transport System");
- entry->module=ConstantString("FTS");
+ entry->flags^=CoderAdjoinFlag;
+ entry->flags|=CoderDecoderSeekableStreamFlag;
(void) RegisterMagickInfo(entry);
return(MagickImageCoderSignature);
}
Image *image,ExceptionInfo *exception)
{
char
+ *fits_info,
header[FITSBlocksize],
- *fits_info;
+ *url;
MagickBooleanType
status;
Open output image file.
*/
assert(image_info != (const ImageInfo *) NULL);
- assert(image_info->signature == MagickSignature);
+ assert(image_info->signature == MagickCoreSignature);
assert(image != (Image *) NULL);
- assert(image->signature == MagickSignature);
+ assert(image->signature == MagickCoreSignature);
if (image->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
assert(exception != (ExceptionInfo *) NULL);
- assert(exception->signature == MagickSignature);
+ assert(exception->signature == MagickCoreSignature);
status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception);
if (status == MagickFalse)
return(status);
- if (IssRGBCompatibleColorspace(image->colorspace) == MagickFalse)
- (void) TransformImageColorspace(image,sRGBColorspace,exception);
+ (void) TransformImageColorspace(image,sRGBColorspace,exception);
/*
Allocate image memory.
*/
*/
image->depth=GetImageQuantumDepth(image,MagickFalse);
image->endian=MSBEndian;
- quantum_info=AcquireQuantumInfo((const ImageInfo *) NULL,image);
+ quantum_info=AcquireQuantumInfo(image_info,image);
if (quantum_info == (QuantumInfo *) NULL)
ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
offset=0;
(void) strncpy(fits_info+offset,header,strlen(header));
offset+=80;
(void) FormatLocaleString(header,FITSBlocksize,"BITPIX = %10ld",
- (long) (quantum_info->format == FloatingPointQuantumFormat ? -1 : 1)*
- image->depth);
+ (long) ((quantum_info->format == FloatingPointQuantumFormat ? -1 : 1)*
+ image->depth));
(void) strncpy(fits_info+offset,header,strlen(header));
offset+=80;
(void) FormatLocaleString(header,FITSBlocksize,"NAXIS = %10lu",
- IsImageGray(image,exception) != MagickFalse ? 2UL : 3UL);
+ SetImageGray(image,exception) != MagickFalse ? 2UL : 3UL);
(void) strncpy(fits_info+offset,header,strlen(header));
offset+=80;
(void) FormatLocaleString(header,FITSBlocksize,"NAXIS1 = %10lu",
(unsigned long) image->rows);
(void) strncpy(fits_info+offset,header,strlen(header));
offset+=80;
- if (IsImageGray(image,exception) == MagickFalse)
+ if (SetImageGray(image,exception) == MagickFalse)
{
(void) FormatLocaleString(header,FITSBlocksize,
"NAXIS3 = %10lu",3UL);
(void) strncpy(fits_info+offset,header,strlen(header));
offset+=80;
}
- (void) FormatLocaleString(header,FITSBlocksize,"HISTORY %.72s",
- GetMagickVersion((size_t *) NULL));
+ url=GetMagickHomeURL();
+ (void) FormatLocaleString(header,FITSBlocksize,"HISTORY %.72s",url);
+ url=DestroyString(url);
(void) strncpy(fits_info+offset,header,strlen(header));
offset+=80;
(void) strncpy(header,"END",FITSBlocksize);
/*
Convert image to fits scale PseudoColor class.
*/
- pixels=GetQuantumPixels(quantum_info);
- if (IsImageGray(image,exception) != MagickFalse)
+ pixels=(unsigned char *) GetQuantumPixels(quantum_info);
+ if (SetImageGray(image,exception) != MagickFalse)
{
length=GetQuantumExtent(image,quantum_info,GrayQuantum);
for (y=(ssize_t) image->rows-1; y >= 0; y--)