]> granicus.if.org Git - imagemagick/blobdiff - coders/fpx.c
Changed signature of ConformPixelInfo.
[imagemagick] / coders / fpx.c
index 67c950c2088e1002b4e577b3eded08022b19dd5c..e3b25507c5a897f2c2c1d75fee6a062d6bc75b99 100644 (file)
 %                     Read/Write FlashPIX Image Format                        %
 %                                                                             %
 %                              Software Design                                %
-%                                John Cristy                                  %
+%                                   Cristy                                    %
 %                                 July 1992                                   %
 %                                                                             %
 %                                                                             %
-%  Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization      %
+%  Copyright 1999-2014 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  %
@@ -39,6 +39,7 @@
 /*
   Include declarations.
 */
+#include "MagickCore/studio.h"
 #include "MagickCore/attribute.h"
 #include "MagickCore/property.h"
 #include "MagickCore/blob.h"
@@ -83,40 +84,6 @@ static MagickBooleanType
   WriteFPXImage(const ImageInfo *,Image *,ExceptionInfo *);
 #endif
 \f
-/*
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%                                                                             %
-%                                                                             %
-%                                                                             %
-%   I s F P X                                                                 %
-%                                                                             %
-%                                                                             %
-%                                                                             %
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-%  IsFPX() returns MagickTrue if the image format type, identified by the
-%  magick string, is FPX.
-%
-%  The format of the IsFPX method is:
-%
-%      MagickBooleanType IsFPX(const unsigned char *magick,const size_t length)
-%
-%  A description of each parameter follows:
-%
-%    o magick: compare image format pattern against these bytes.
-%
-%    o length: Specifies the length of the magick string.
-%
-*/
-static MagickBooleanType IsFPX(const unsigned char *magick,const size_t length)
-{
-  if (length < 4)
-    return(MagickFalse);
-  if (memcmp(magick,"\320\317\021\340",4) == 0)
-    return(MagickTrue);
-  return(MagickFalse);
-}
-\f
 #if defined(MAGICKCORE_FPX_DELEGATE)
 /*
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -217,7 +184,7 @@ static Image *ReadFPXImage(const ImageInfo *image_info,ExceptionInfo *exception)
       image_info->filename);
   assert(exception != (ExceptionInfo *) NULL);
   assert(exception->signature == MagickSignature);
-  image=AcquireImage(image_info);
+  image=AcquireImage(image_info,exception);
   status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
   if (status == MagickFalse)
     {
@@ -313,7 +280,7 @@ static Image *ReadFPXImage(const ImageInfo *image_info,ExceptionInfo *exception)
           }
         (void) CopyMagickString(label,(char *) summary_info.title.ptr,
           summary_info.title.length+1);
-        (void) SetImageProperty(image,"label",label);
+        (void) SetImageProperty(image,"label",label,exception);
         label=DestroyString(label);
       }
   if (summary_info.comments_valid)
@@ -337,7 +304,7 @@ static Image *ReadFPXImage(const ImageInfo *image_info,ExceptionInfo *exception)
           }
         (void) CopyMagickString(comments,(char *) summary_info.comments.ptr,
           summary_info.comments.length+1);
-        (void) SetImageProperty(image,"comment",comments);
+        (void) SetImageProperty(image,"comment",comments,exception);
         comments=DestroyString(comments);
       }
   /*
@@ -365,13 +332,13 @@ static Image *ReadFPXImage(const ImageInfo *image_info,ExceptionInfo *exception)
   image->columns=width;
   image->rows=height;
   if ((colorspace.numberOfComponents % 2) == 0)
-    image->matte=MagickTrue;
+    image->alpha_trait=BlendPixelTrait;
   if (colorspace.numberOfComponents == 1)
     {
       /*
         Create linear colormap.
       */
-      if (AcquireImageColormap(image,MaxColormapSize) == MagickFalse)
+      if (AcquireImageColormap(image,MaxColormapSize,exception) == MagickFalse)
         {
           FPX_ClearSystem();
           ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
@@ -472,7 +439,7 @@ static Image *ReadFPXImage(const ImageInfo *image_info,ExceptionInfo *exception)
           SetPixelBlue(image,index,q);
         }
       SetPixelAlpha(image,OpaqueAlpha,q);
-      if (image->matte != MagickFalse)
+      if (image->alpha_trait == BlendPixelTrait)
         SetPixelAlpha(image,ScaleCharToQuantum(*a),q);
       q+=GetPixelChannels(image);
       r+=red_component->columnStride;
@@ -530,7 +497,6 @@ ModuleExport size_t RegisterFPXImage(void)
   entry->adjoin=MagickFalse;
   entry->seekable_stream=MagickTrue;
   entry->blob_support=MagickFalse;
-  entry->magick=(IsImageFormatHandler *) IsFPX;
   entry->description=ConstantString("FlashPix Format");
   entry->module=ConstantString("FPX");
   (void) RegisterMagickInfo(entry);
@@ -852,13 +818,12 @@ static MagickBooleanType WriteFPXImage(const ImageInfo *image_info,Image *image,
   status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception);
   if (status == MagickFalse)
     return(status);
+  (void) TransformImageColorspace(image,sRGBColorspace,exception);
   (void) CloseBlob(image);
   /*
     Initialize FPX toolkit.
   */
   image->depth=8;
-  if (IsRGBColorspace(image->colorspace) == MagickFalse)
-    (void) TransformImageColorspace(image,RGBColorspace);
   memory_limit=20000000;
   fpx_status=FPX_SetToolkitMemoryLimit(&memory_limit);
   if (fpx_status != FPX_OK)
@@ -866,7 +831,7 @@ static MagickBooleanType WriteFPXImage(const ImageInfo *image_info,Image *image,
   tile_width=64;
   tile_height=64;
   colorspace.numberOfComponents=3;
-  if (image->matte != MagickFalse)
+  if (image->alpha_trait == BlendPixelTrait)
     colorspace.numberOfComponents=4;
   if ((image_info->type != TrueColorType) &&
       (IsImageGray(image,exception) != MagickFalse))
@@ -929,12 +894,10 @@ static MagickBooleanType WriteFPXImage(const ImageInfo *image_info,Image *image,
   summary_info.thumbnail_valid=MagickFalse;
   summary_info.appname_valid=MagickFalse;
   summary_info.security_valid=MagickFalse;
-  label=GetImageProperty(image,"label");
+  summary_info.title.ptr=(unsigned char *) NULL;
+  label=GetImageProperty(image,"label",exception);
   if (label != (const char *) NULL)
     {
-      size_t
-        length;
-
       /*
         Note image label.
       */
@@ -949,7 +912,7 @@ static MagickBooleanType WriteFPXImage(const ImageInfo *image_info,Image *image,
       (void) CopyMagickString((char *) summary_info.title.ptr,label,
         MaxTextExtent);
     }
-  comment=GetImageProperty(image,"comment");
+  comment=GetImageProperty(image,"comment",exception);
   if (comment != (const char *) NULL)
     {
       /*
@@ -989,7 +952,7 @@ static MagickBooleanType WriteFPXImage(const ImageInfo *image_info,Image *image,
     Write image pixelss.
   */
   quantum_type=RGBQuantum;
-  if (image->matte != MagickFalse)
+  if (image->alpha_trait == BlendPixelTrait)
     quantum_type=RGBAQuantum;
   if (fpx_info.numberOfComponents == 1)
     quantum_type=GrayQuantum;
@@ -1041,7 +1004,7 @@ static MagickBooleanType WriteFPXImage(const ImageInfo *image_info,Image *image,
         Initialize default viewing parameters.
       */
       contrast=1.0;
-      contrast_valid=MagickFalse;
+      contrast_valid=MagickTrue;
       color_twist.byy=1.0;
       color_twist.byc1=0.0;
       color_twist.byc2=0.0;
@@ -1058,16 +1021,16 @@ static MagickBooleanType WriteFPXImage(const ImageInfo *image_info,Image *image,
       color_twist.dummy5_zero=0.0;
       color_twist.dummy6_zero=0.0;
       color_twist.dummy7_one=1.0;
-      color_twist_valid=MagickFalse;
+      color_twist_valid=MagickTrue;
       sharpen=0.0;
-      sharpen_valid=MagickFalse;
+      sharpen_valid=MagickTrue;
       aspect_ratio=(double) image->columns/image->rows;
-      aspect_ratio_valid=MagickFalse;
+      aspect_ratio_valid=MagickTrue;
       view_rect.left=(float) 0.1;
       view_rect.width=aspect_ratio-0.2;
       view_rect.top=(float) 0.1;
       view_rect.height=(float) 0.8; /* 1.0-0.2 */
-      view_rect_valid=MagickFalse;
+      view_rect_valid=MagickTrue;
       affine.a11=1.0;
       affine.a12=0.0;
       affine.a13=0.0;
@@ -1084,7 +1047,7 @@ static MagickBooleanType WriteFPXImage(const ImageInfo *image_info,Image *image,
       affine.a42=0.0;
       affine.a43=0.0;
       affine.a44=1.0;
-      affine_valid=MagickFalse;
+      affine_valid=MagickTrue;
       if (0)
         {
           /*
@@ -1095,37 +1058,37 @@ static MagickBooleanType WriteFPXImage(const ImageInfo *image_info,Image *image,
           SetColorBalance(0.5,1.0,1.0,&color_twist);
           color_twist_valid=MagickTrue;
         }
-      if (affine_valid)
+      if (affine_valid != MagickFalse)
         {
           fpx_status=FPX_SetImageAffineMatrix(flashpix,&affine);
           if (fpx_status != FPX_OK)
             ThrowWriterException(DelegateError,"UnableToSetAffineMatrix");
         }
-      if (aspect_ratio_valid)
+      if (aspect_ratio_valid != MagickFalse)
         {
           fpx_status=FPX_SetImageResultAspectRatio(flashpix,&aspect_ratio);
           if (fpx_status != FPX_OK)
             ThrowWriterException(DelegateError,"UnableToSetAspectRatio");
         }
-      if (color_twist_valid)
+      if (color_twist_valid != MagickFalse)
         {
           fpx_status=FPX_SetImageColorTwistMatrix(flashpix,&color_twist);
           if (fpx_status != FPX_OK)
             ThrowWriterException(DelegateError,"UnableToSetColorTwist");
         }
-      if (contrast_valid)
+      if (contrast_valid != MagickFalse)
         {
           fpx_status=FPX_SetImageContrastAdjustment(flashpix,&contrast);
           if (fpx_status != FPX_OK)
             ThrowWriterException(DelegateError,"UnableToSetContrast");
         }
-      if (sharpen_valid)
+      if (sharpen_valid != MagickFalse)
         {
           fpx_status=FPX_SetImageFilteringValue(flashpix,&sharpen);
           if (fpx_status != FPX_OK)
             ThrowWriterException(DelegateError,"UnableToSetFilteringValue");
         }
-      if (view_rect_valid)
+      if (view_rect_valid != MagickFalse)
         {
           fpx_status=FPX_SetImageROI(flashpix,&view_rect);
           if (fpx_status != FPX_OK)