@@ -632,15 +632,10 @@ int msEmbedLegend(mapObj *map, imageObj *img)
632
632
pointObj point ;
633
633
imageObj * image = NULL ;
634
634
symbolObj * legendSymbol ;
635
+ char * imageType = NULL ;
635
636
636
637
rendererVTableObj * renderer ;
637
638
638
- if (!MS_RENDERER_PLUGIN (map -> outputformat ) || !MS_MAP_RENDERER (map )-> supports_pixel_buffer ) {
639
- msSetError (MS_MISCERR , "unsupported output format" , "msEmbedLegend()" );
640
- return MS_FAILURE ;
641
- }
642
- renderer = MS_MAP_RENDERER (map );
643
-
644
639
s = msGetSymbolIndex (& (map -> symbolset ), "legend" , MS_FALSE );
645
640
if (s != -1 )
646
641
msRemoveSymbol (& (map -> symbolset ), s ); /* solves some caching issues in AGG with long-running processes */
@@ -652,10 +647,26 @@ int msEmbedLegend(mapObj *map, imageObj *img)
652
647
map -> symbolset .numsymbols ++ ;
653
648
initSymbol (legendSymbol );
654
649
650
+ if (!MS_RENDERER_PLUGIN (map -> outputformat ) || !MS_MAP_RENDERER (map )-> supports_pixel_buffer ) {
651
+ imageType = msStrdup (map -> imagetype ); /* save format */
652
+ if MS_DRIVER_CAIRO (map -> outputformat )
653
+ map -> outputformat = msSelectOutputFormat ( map , "cairopng" );
654
+ else
655
+ map -> outputformat = msSelectOutputFormat ( map , "png" );
656
+
657
+ msInitializeRendererVTable (map -> outputformat );
658
+ }
659
+ renderer = MS_MAP_RENDERER (map );
660
+
655
661
/* render the legend. */
656
662
image = msDrawLegend (map , MS_FALSE );
657
663
if ( image == NULL ) return -1 ;
658
664
665
+ if (imageType ) {
666
+ map -> outputformat = msSelectOutputFormat ( map , imageType ); /* restore format */
667
+ msFree (imageType );
668
+ }
669
+
659
670
/* copy renderered legend image into symbol */
660
671
legendSymbol -> pixmap_buffer = calloc (1 ,sizeof (rasterBufferObj ));
661
672
MS_CHECK_ALLOC (legendSymbol -> pixmap_buffer , sizeof (rasterBufferObj ), MS_FAILURE );
0 commit comments