]> granicus.if.org Git - imagemagick/blobdiff - coders/mtv.c
Removed png_write_chunk_from_profile()
[imagemagick] / coders / mtv.c
index 09f2692be0fc38dcc73b102805d416d40c5ef8c7..688248a592aab2802778cbde9231222b7d78e6b5 100644 (file)
 %                   Read/Write MTV Raytracer Image Format                     %
 %                                                                             %
 %                              Software Design                                %
-%                                John Cristy                                  %
+%                                   Cristy                                    %
 %                                 July 1992                                   %
 %                                                                             %
 %                                                                             %
-%  Copyright 1999-2011 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  %
 %  obtain a copy of the License at                                            %
 %                                                                             %
-%    http://www.imagemagick.org/script/license.php                            %
+%    https://www.imagemagick.org/script/license.php                           %
 %                                                                             %
 %  Unless required by applicable law or agreed to in writing, software        %
 %  distributed under the License is distributed on an "AS IS" BASIS,          %
@@ -95,7 +95,7 @@ static MagickBooleanType
 static Image *ReadMTVImage(const ImageInfo *image_info,ExceptionInfo *exception)
 {
   char
-    buffer[MaxTextExtent];
+    buffer[MagickPathExtent];
 
   Image
     *image;
@@ -127,13 +127,13 @@ static Image *ReadMTVImage(const ImageInfo *image_info,ExceptionInfo *exception)
     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);
-  image=AcquireImage(image_info);
+  assert(exception->signature == MagickCoreSignature);
+  image=AcquireImage(image_info,exception);
   status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
   if (status == MagickFalse)
     {
@@ -158,10 +158,13 @@ static Image *ReadMTVImage(const ImageInfo *image_info,ExceptionInfo *exception)
     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));
     /*
       Convert MTV raster image to pixel packets.
     */
-    pixels=(unsigned char *) AcquireQuantumMemory((size_t) image->columns,
+    pixels=(unsigned char *) AcquireQuantumMemory(image->columns,
       3UL*sizeof(*pixels));
     if (pixels == (unsigned char *) NULL)
       ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
@@ -169,10 +172,13 @@ static Image *ReadMTVImage(const ImageInfo *image_info,ExceptionInfo *exception)
     {
       count=(ssize_t) ReadBlob(image,(size_t) (3*image->columns),pixels);
       if (count != (ssize_t) (3*image->columns))
-        ThrowReaderException(CorruptImageError,"UnableToReadImageData");
+        {
+          pixels=(unsigned char *) RelinquishMagickMemory(pixels);
+          ThrowReaderException(CorruptImageError,"UnableToReadImageData");
+        }
       p=pixels;
       q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
-      if (q == (const Quantum *) NULL)
+      if (q == (Quantum *) NULL)
         break;
       for (x=0; x < (ssize_t) image->columns; x++)
       {
@@ -213,7 +219,7 @@ static Image *ReadMTVImage(const ImageInfo *image_info,ExceptionInfo *exception)
         /*
           Allocate next image structure.
         */
-        AcquireNextImage(image_info,image);
+        AcquireNextImage(image_info,image,exception);
         if (GetNextImageInList(image) == (Image *) NULL)
           {
             image=DestroyImageList(image);
@@ -258,11 +264,9 @@ ModuleExport size_t RegisterMTVImage(void)
   MagickInfo
     *entry;
 
-  entry=SetMagickInfo("MTV");
+  entry=AcquireMagickInfo("MTV","MTV","MTV Raytracing image format");
   entry->decoder=(DecodeImageHandler *) ReadMTVImage;
   entry->encoder=(EncodeImageHandler *) WriteMTVImage;
-  entry->description=ConstantString("MTV Raytracing image format");
-  entry->module=ConstantString("MTV");
   (void) RegisterMagickInfo(entry);
   return(MagickImageCoderSignature);
 }
@@ -323,7 +327,7 @@ static MagickBooleanType WriteMTVImage(const ImageInfo *image_info,Image *image,
   ExceptionInfo *exception)
 {
   char
-    buffer[MaxTextExtent];
+    buffer[MagickPathExtent];
 
   MagickBooleanType
     status;
@@ -350,13 +354,13 @@ static MagickBooleanType WriteMTVImage(const ImageInfo *image_info,Image *image,
     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);
@@ -366,16 +370,15 @@ static MagickBooleanType WriteMTVImage(const ImageInfo *image_info,Image *image,
     /*
       Allocate memory for pixels.
     */
-    if (IsRGBColorspace(image->colorspace) == MagickFalse)
-      (void) TransformImageColorspace(image,RGBColorspace);
-    pixels=(unsigned char *) AcquireQuantumMemory((size_t) image->columns,
+    (void) TransformImageColorspace(image,sRGBColorspace,exception);
+    pixels=(unsigned char *) AcquireQuantumMemory(image->columns,
       3UL*sizeof(*pixels));
     if (pixels == (unsigned char *) NULL)
       ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
     /*
       Initialize raster file header.
     */
-    (void) FormatLocaleString(buffer,MaxTextExtent,"%.20g %.20g\n",(double)
+    (void) FormatLocaleString(buffer,MagickPathExtent,"%.20g %.20g\n",(double)
       image->columns,(double) image->rows);
     (void) WriteBlobString(image,buffer);
     for (y=0; y < (ssize_t) image->rows; y++)