% Read/Write Scalable Vector Graphics Format %
% %
% Software Design %
-% John Cristy %
+% Cristy %
% William Radcliffe %
% March 2000 %
% %
% %
-% Copyright 1999-2013 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 %
if (svg_info->text != (char *) NULL)
svg_info->text=DestroyString(svg_info->text);
if (svg_info->scale != (double *) NULL)
- svg_info->scale=(double *) (svg_info->scale);
+ svg_info->scale=(double *) RelinquishMagickMemory(svg_info->scale);
if (svg_info->title != (char *) NULL)
svg_info->title=DestroyString(svg_info->title);
if (svg_info->comment != (char *) NULL)
cairo_t
*cairo_image;
+ MemoryInfo
+ *pixel_info;
+
register unsigned char
*p;
#else
GdkPixbuf
- *pixel_info;
+ *pixel_buffer;
register const guchar
*p;
if (svg_handle == (RsvgHandle *) NULL)
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
rsvg_handle_set_base_uri(svg_handle,image_info->filename);
- rsvg_handle_set_dpi_x_y(svg_handle,image->resolution.x,
- image->resolution.y);
+ if ((image->resolution.x != 90.0) && (image->resolution.y != 90.0))
+ rsvg_handle_set_dpi_x_y(svg_handle,image->resolution.x,
+ image->resolution.y);
while ((n=ReadBlob(image,MaxTextExtent,message)) != 0)
{
error=(GError *) NULL;
g_error_free(error);
#if defined(MAGICKCORE_CAIRO_DELEGATE)
rsvg_handle_get_dimensions(svg_handle,&dimension_info);
- image->columns=image->resolution.x*dimension_info.width/72.0;
- image->rows=image->resolution.y*dimension_info.height/72.0;
- pixels=(unsigned char *) NULL;
+ image->columns=image->resolution.x*dimension_info.width/90.0;
+ image->rows=image->resolution.y*dimension_info.height/90.0;
+ pixel_info=(MemoryInfo *) NULL;
#else
- pixel_info=rsvg_handle_get_pixbuf(svg_handle);
+ pixel_buffer=rsvg_handle_get_pixbuf(svg_handle);
rsvg_handle_free(svg_handle);
- image->columns=gdk_pixbuf_get_width(pixel_info);
- image->rows=gdk_pixbuf_get_height(pixel_info);
+ image->columns=gdk_pixbuf_get_width(pixel_buffer);
+ image->rows=gdk_pixbuf_get_height(pixel_buffer);
#endif
image->alpha_trait=BlendPixelTrait;
SetImageProperty(image,"svg:base-uri",
if ((image->columns == 0) || (image->rows == 0))
{
#if !defined(MAGICKCORE_CAIRO_DELEGATE)
- g_object_unref(G_OBJECT(pixel_info));
+ g_object_unref(G_OBJECT(pixel_buffer));
#endif
g_object_unref(svg_handle);
ThrowReaderException(MissingDelegateError,
stride=(size_t) cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32,
image->columns);
#endif
- pixels=(unsigned char *) AcquireQuantumMemory(stride,image->rows*
- sizeof(*pixels));
- if (pixels == (unsigned char *) NULL)
+ pixel_info=AcquireVirtualMemory(stride,image->rows*sizeof(*pixels));
+ if (pixel_info == (MemoryInfo *) NULL)
{
g_object_unref(svg_handle);
ThrowReaderException(ResourceLimitError,
"MemoryAllocationFailed");
}
+ pixels=(unsigned char *) GetVirtualMemoryBlob(pixel_info);
#endif
(void) SetImageBackgroundColor(image,exception);
#if defined(MAGICKCORE_CAIRO_DELEGATE)
CAIRO_FORMAT_ARGB32,image->columns,image->rows,stride);
if (cairo_surface == (cairo_surface_t *) NULL)
{
- pixels=(unsigned char *) RelinquishMagickMemory(pixels);
+ pixel_info=RelinquishVirtualMemory(pixel_info);
g_object_unref(svg_handle);
ThrowReaderException(ResourceLimitError,
"MemoryAllocationFailed");
cairo_set_operator(cairo_image,CAIRO_OPERATOR_CLEAR);
cairo_paint(cairo_image);
cairo_set_operator(cairo_image,CAIRO_OPERATOR_OVER);
- cairo_scale(cairo_image,image->resolution.x/72.0,
- image->resolution.y/72.0);
+ cairo_scale(cairo_image,image->resolution.x/90.0,
+ image->resolution.y/90.0);
rsvg_handle_render_cairo(svg_handle,cairo_image);
cairo_destroy(cairo_image);
cairo_surface_destroy(cairo_surface);
g_object_unref(svg_handle);
p=pixels;
#else
- p=gdk_pixbuf_get_pixels(pixel_info);
+ p=gdk_pixbuf_get_pixels(pixel_buffer);
#endif
GetPixelInfo(image,&fill_color);
for (y=0; y < (ssize_t) image->rows; y++)
}
}
#if defined(MAGICKCORE_CAIRO_DELEGATE)
- if (pixels != (unsigned char *) NULL)
- pixels=(unsigned char *) RelinquishMagickMemory(pixels);
+ if (pixel_info != (MemoryInfo *) NULL)
+ pixel_info=RelinquishVirtualMemory(pixel_info);
#else
- g_object_unref(G_OBJECT(pixel_info));
+ g_object_unref(G_OBJECT(pixel_buffer));
#endif
(void) CloseBlob(image);
return(GetFirstImageInList(image));
/*
Parse SVG file.
*/
+ if (image == (Image *) NULL)
+ return((Image *) NULL);
svg_info=AcquireSVGInfo();
if (svg_info == (SVGInfo *) NULL)
- ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
+ {
+ (void) fclose(file);
+ ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
+ }
svg_info->file=file;
svg_info->exception=exception;
svg_info->image=image;
(void) CloneString(&svg_info->size,image_info->size);
if (image->debug != MagickFalse)
(void) LogMagickEvent(CoderEvent,GetMagickModule(),"begin SAX");
- xmlInitParser();
(void) xmlSubstituteEntitiesDefault(1);
(void) ResetMagickMemory(&sax_modules,0,sizeof(sax_modules));
sax_modules.internalSubset=SVGInternalSubset;
xmlFreeParserCtxt(svg_info->parser);
if (image->debug != MagickFalse)
(void) LogMagickEvent(CoderEvent,GetMagickModule(),"end SAX");
- xmlCleanupParser();
(void) fclose(file);
(void) CloseBlob(image);
image->columns=svg_info->width;
(void) CopyMagickString(version,"XML " LIBXML_DOTTED_VERSION,MaxTextExtent);
#endif
#if defined(MAGICKCORE_RSVG_DELEGATE)
+#if !GLIB_CHECK_VERSION(2,35,0)
g_type_init();
+#endif
+#if defined(MAGICKCORE_XML_DELEGATE)
+ xmlInitParser();
+#endif
(void) FormatLocaleString(version,MaxTextExtent,"RSVG %d.%d.%d",
LIBRSVG_MAJOR_VERSION,LIBRSVG_MINOR_VERSION,LIBRSVG_MICRO_VERSION);
#endif
entry->blob_support=MagickFalse;
entry->seekable_stream=MagickFalse;
entry->description=ConstantString("Scalable Vector Graphics");
+ entry->mime_type=ConstantString("image/svg+xml");
if (*version != '\0')
entry->version=ConstantString(version);
entry->magick=(IsImageFormatHandler *) IsSVG;
entry->blob_support=MagickFalse;
entry->seekable_stream=MagickFalse;
entry->description=ConstantString("Compressed Scalable Vector Graphics");
+ entry->mime_type=ConstantString("image/svg+xml");
if (*version != '\0')
entry->version=ConstantString(version);
entry->magick=(IsImageFormatHandler *) IsSVG;
(void) UnregisterMagickInfo("SVGZ");
(void) UnregisterMagickInfo("SVG");
(void) UnregisterMagickInfo("MSVG");
+#if defined(MAGICKCORE_XML_DELEGATE)
+ xmlCleanupParser();
+#endif
}
\f
/*