% Read/Write Magick Vector Graphics Metafiles. %
% %
% Software Design %
-% John Cristy %
+% Cristy %
% April 2000 %
% %
% %
-% Copyright 1999-2010 ImageMagick Studio LLC, a non-profit organization %
+% Copyright 1999-2015 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 %
/*
Include declarations.
*/
-#include "magick/studio.h"
-#include "magick/artifact.h"
-#include "magick/blob.h"
-#include "magick/blob-private.h"
-#include "magick/draw.h"
-#include "magick/exception.h"
-#include "magick/exception-private.h"
-#include "magick/image.h"
-#include "magick/image-private.h"
-#include "magick/list.h"
-#include "magick/magick.h"
-#include "magick/memory_.h"
-#include "magick/module.h"
-#include "magick/property.h"
-#include "magick/quantum-private.h"
-#include "magick/static.h"
-#include "magick/string_.h"
+#include "MagickCore/studio.h"
+#include "MagickCore/artifact.h"
+#include "MagickCore/blob.h"
+#include "MagickCore/blob-private.h"
+#include "MagickCore/draw.h"
+#include "MagickCore/exception.h"
+#include "MagickCore/exception-private.h"
+#include "MagickCore/image.h"
+#include "MagickCore/image-private.h"
+#include "MagickCore/list.h"
+#include "MagickCore/magick.h"
+#include "MagickCore/memory_.h"
+#include "MagickCore/module.h"
+#include "MagickCore/property.h"
+#include "MagickCore/quantum-private.h"
+#include "MagickCore/static.h"
+#include "MagickCore/string_.h"
\f
/*
Forward declarations.
*/
static MagickBooleanType
- WriteMVGImage(const ImageInfo *,Image *);
+ WriteMVGImage(const ImageInfo *,Image *,ExceptionInfo *);
\f
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
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)
{
continue;
(void) sscanf(p,"viewbox %lf %lf %lf %lf",&bounds.x1,&bounds.y1,
&bounds.x2,&bounds.y2);
- image->columns=(unsigned long) ((bounds.x2-bounds.x1)+0.5);
- image->rows=(unsigned long) ((bounds.y2-bounds.y1)+0.5);
+ image->columns=(size_t) floor((bounds.x2-bounds.x1)+0.5);
+ image->rows=(size_t) floor((bounds.y2-bounds.y1)+0.5);
break;
}
}
if ((image->columns == 0) || (image->rows == 0))
ThrowReaderException(OptionError,"MustSpecifyImageSize");
draw_info=CloneDrawInfo(image_info,(DrawInfo *) NULL);
- draw_info->affine.sx=image->x_resolution == 0.0 ? 1.0 : image->x_resolution/
+ draw_info->affine.sx=image->resolution.x == 0.0 ? 1.0 : image->resolution.x/
DefaultResolution;
- draw_info->affine.sy=image->y_resolution == 0.0 ? 1.0 : image->y_resolution/
+ draw_info->affine.sy=image->resolution.y == 0.0 ? 1.0 : image->resolution.y/
DefaultResolution;
- image->columns=(unsigned long) (draw_info->affine.sx*image->columns);
- image->rows=(unsigned long) (draw_info->affine.sy*image->rows);
- (void) SetImageBackgroundColor(image);
+ image->columns=(size_t) (draw_info->affine.sx*image->columns);
+ image->rows=(size_t) (draw_info->affine.sy*image->rows);
+ status=SetImageExtent(image,image->columns,image->rows,exception);
+ if (status == MagickFalse)
+ return(DestroyImageList(image));
+ if (SetImageBackgroundColor(image,exception) == MagickFalse)
+ {
+ image=DestroyImageList(image);
+ return((Image *) NULL);
+ }
/*
Render drawing.
*/
draw_info->primitive[GetBlobSize(image)]='\0';
}
}
- (void) DrawImage(image,draw_info);
+ (void) DrawImage(image,draw_info,exception);
draw_info=DestroyDrawInfo(draw_info);
(void) CloseBlob(image);
return(GetFirstImageInList(image));
%
% The format of the RegisterMVGImage method is:
%
-% unsigned long RegisterMVGImage(void)
+% size_t RegisterMVGImage(void)
%
*/
-ModuleExport unsigned long RegisterMVGImage(void)
+ModuleExport size_t RegisterMVGImage(void)
{
MagickInfo
*entry;
entry->decoder=(DecodeImageHandler *) ReadMVGImage;
entry->encoder=(EncodeImageHandler *) WriteMVGImage;
entry->magick=(IsImageFormatHandler *) IsMVG;
- entry->adjoin=MagickFalse;
- entry->seekable_stream=MagickTrue;
+ entry->flags^=CoderAdjoinFlag;
+ entry->flags|=CoderSeekableStreamFlag;
entry->description=ConstantString("Magick Vector Graphics");
entry->module=ConstantString("MVG");
(void) RegisterMagickInfo(entry);
%
% The format of the WriteMVGImage method is:
%
-% MagickBooleanType WriteMVGImage(const ImageInfo *image_info,Image *image)
+% MagickBooleanType WriteMVGImage(const ImageInfo *image_info,
+% Image *image,ExceptionInfo *exception)
%
% A description of each parameter follows.
%
%
% o image: The image.
%
+% o exception: return any errors or warnings in this structure.
+%
*/
-static MagickBooleanType WriteMVGImage(const ImageInfo *image_info,Image *image)
+static MagickBooleanType WriteMVGImage(const ImageInfo *image_info,Image *image,
+ ExceptionInfo *exception)
{
const char
*value;
value=GetImageArtifact(image,"MVG");
if (value == (const char *) NULL)
ThrowWriterException(OptionError,"NoImageVectorGraphics");
- status=OpenBlob(image_info,image,WriteBlobMode,&image->exception);
+ status=OpenBlob(image_info,image,WriteBlobMode,exception);
if (status == MagickFalse)
return(status);
(void) WriteBlob(image,strlen(value),(const unsigned char *) value);