Index: src/dot.cpp
===================================================================
--- src/dot.cpp	(Revision 593)
+++ src/dot.cpp	(Arbeitskopie)
@@ -39,8 +39,10 @@
 #include <qfile.h>
 #include <qtextstream.h>
 #include <md5.h>
+#include <png.h>
 
 #define MAP_CMD "cmap"
+#define SVG_SCALE 1.04
 
 //--------------------------------------------------------------------
 
@@ -1088,6 +1090,7 @@
 
       DotRunner dotRun(dotName);
       dotRun.addJob(imgExt,imgName);
+      if (imgExt == "svg") dotRun.addJob("png",baseName+".png");
       dotRun.addJob(MAP_CMD,mapName);
       if (!dotRun.run())
       {
@@ -1096,12 +1099,29 @@
       }
       
       checkDotResult(imgName);
+      if (imgExt == "svg") checkDotResult(baseName+".png");
       if (Config_getBool("DOT_CLEANUP")) thisDir.remove(dotName);
     }
     // write image and map in a table row
     QCString mapLabel = convertNameToFile(n->m_label);
-    out << "<tr><td><img src=\"" << imgName << "\" border=\"0\" alt=\"\" usemap=\"#" 
-      << mapLabel << "_map\">" << endl;
+    out << "<tr><td>";
+    if (imgExt == "svg")
+    {
+      unsigned png_width = 0, png_height = 0;
+    
+      getPngImageSize(NULL, baseName+".png", &png_width, &png_height);
+      out << "<object data=\"" << imgName << "\" " 
+        << "type=\"image/svg+xml\" width=\"" << png_width * SVG_SCALE << "\" height=\"" << png_height * SVG_SCALE << "\" "
+        << "border=\"0\" usemap=\"#" << mapName << "\">" << endl
+        << "<param name=\"src\" value=\"" << imgName << "\">" << endl;
+      out << "<img src=\"" << baseName+".png" << "\" border=\"0\" alt=\"\" usemap=\"#" << mapLabel << "_map\">" << endl;
+      out << "</object>" << endl;
+    }
+    else
+    {
+      out << "<img src=\"" << imgName << "\" border=\"0\" alt=\"\" usemap=\"#" 
+        << mapLabel << "_map\">" << endl;
+    }
     out << "<map name=\"" << mapLabel << "_map\">" << endl;
     convertMapFile(out,mapName,"");
     out << "</map></td></tr>" << endl;
@@ -1844,6 +1864,7 @@
 
       DotRunner dotRun(baseName+".dot");
       dotRun.addJob(imgExt,imgName);
+      if (imgExt == "svg") dotRun.addJob("png",baseName+".png");
       if (generateImageMap) dotRun.addJob(MAP_CMD,baseName+".map");
       if (!dotRun.run())
       {
@@ -1852,6 +1873,7 @@
       }
 
       checkDotResult(imgName);
+      if (imgExt == "svg") checkDotResult(baseName+".png");
     }
     else if (format==EPS) // run dot to create a .eps image
     {
@@ -1883,22 +1905,43 @@
   if (format==BITMAP && generateImageMap) // produce HTML to include the image
   {
     QCString mapLabel = convertNameToFile(m_startNode->m_label+"_"+mapName);
-    out << "<p><center><img src=\"" << relPath << baseName << "." 
-      << imgExt << "\" border=\"0\" usemap=\"#"
-      << mapLabel << "\" alt=\"";
+    QCString graphType;
     switch (m_graphType)
     {
       case DotNode::Collaboration:
-        out << "Collaboration graph";
+        graphType = "Collaboration graph";
         break;
       case DotNode::Inheritance:
-        out << "Inheritance graph";
+        graphType = "Inheritance graph";
         break;
       default:
         ASSERT(0);
         break;
     }
-    out << "\"></center>" << endl;
+
+    out << "<p><center>";
+    if (imgExt == "svg")
+    {
+      unsigned png_width = 0, png_height = 0;
+    
+      getPngImageSize(NULL, baseName+".png", &png_width, &png_height);
+      out << "<object data=\"" << relPath << baseName << "." << imgExt << "\" "
+        << "type=\"image/svg+xml\" width=\"" << png_width * SVG_SCALE << "\" height=\"" << png_height * SVG_SCALE << "\" "
+        << "border=\"0\" usemap=\"#" << mapLabel << "\">" << endl
+        << "<param name=\"src\" value=\"" << relPath << baseName << "." << imgExt << "\">" << endl;
+      out << "<img src=\"" << relPath << baseName << "." 
+        << "png" << "\" border=\"0\" usemap=\"#"
+        << mapLabel << "\" alt=\"" << graphType << "\">" << endl;
+      out << "</object>" << endl;
+    }
+    else
+    {
+      out << "<img src=\"" << relPath << baseName << "." 
+        << imgExt << "\" border=\"0\" usemap=\"#"
+        << mapLabel << "\" alt=\"" << graphType << "\">";
+    }
+    out << "</center>" << endl;
+
     QString tmpstr;
     QTextOStream tmpout(&tmpstr);
     tmpout.setEncoding(tmpout.UnicodeUTF8);
@@ -2177,6 +2220,7 @@
       QCString imgName=baseName+"."+imgExt;
       DotRunner dotRun(baseName+".dot");
       dotRun.addJob(imgExt,imgName);
+      if (imgExt == "svg") dotRun.addJob("png",baseName+".png");
       if (generateImageMap) dotRun.addJob(MAP_CMD,baseName+".map");
       if (!dotRun.run())
       {
@@ -2184,6 +2228,7 @@
         return baseName;
       }
       checkDotResult(imgName);
+      if (imgExt == "svg") checkDotResult(baseName+".png");
     }
     else if (format==EPS)
     {
@@ -2212,10 +2257,27 @@
 
   if (format==BITMAP && generateImageMap)
   {
-    out << "<p><center><img src=\"" << relPath << baseName << "." 
-        << imgExt << "\" border=\"0\" usemap=\"#"
-        << mapName << "_map\" alt=\"";
-    out << "\">";
+    out << "<p><center>";
+    if (imgExt == "svg")
+    {
+      unsigned png_width = 0, png_height = 0;
+    
+      getPngImageSize(NULL, baseName+".png", &png_width, &png_height);
+      out << "<object data=\"" << relPath << baseName << "." << imgExt << "\" "
+        << "type=\"image/svg+xml\" width=\"" << png_width * SVG_SCALE << "\" height=\"" << png_height * SVG_SCALE << "\" "
+        << "border=\"0\" usemap=\"#" << mapName << "\">" << endl
+        << "<param name=\"src\" value=\"" << relPath << baseName << "." << imgExt << "\">" << endl;
+      out << "<img src=\"" << relPath << baseName << "." 
+        << "png" << "\" border=\"0\" usemap=\"#"
+        << mapName << "\" alt=\"\">" << endl;
+      out << "</object>" << endl;
+    }
+    else
+    {
+      out << "<img src=\"" << relPath << baseName << "." 
+          << imgExt << "\" border=\"0\" usemap=\"#"
+          << mapName << "_map\" alt=\"\">";
+    }
     out << "</center>" << endl;
     QString tmpstr;
     QTextOStream tmpout(&tmpstr);
@@ -2470,6 +2532,7 @@
       QCString imgName=baseName+"."+imgExt;
       DotRunner dotRun(baseName+".dot");
       dotRun.addJob(imgExt,imgName);
+      if (imgExt == "svg") dotRun.addJob("png",baseName+".png");
       if (generateImageMap) dotRun.addJob(MAP_CMD,baseName+".map");
       if (!dotRun.run())
       {
@@ -2477,6 +2540,7 @@
         return baseName;
       }
       checkDotResult(imgName);
+      if (imgExt == "svg") checkDotResult(baseName+".png");
     }
     else if (format==EPS)
     {
@@ -2505,10 +2569,27 @@
 
   if (format==BITMAP && generateImageMap)
   {
-    out << "<p><center><img src=\"" << relPath << baseName << "." 
-        << imgExt << "\" border=\"0\" usemap=\"#"
-        << mapName << "_map\" alt=\"";
-    out << "\">";
+    out << "<p><center>";
+    if (imgExt == "svg")
+    {
+      unsigned png_width = 0, png_height = 0;
+    
+      getPngImageSize(NULL, baseName+".png", &png_width, &png_height);
+      out << "<object data=\"" << relPath << baseName << "." << imgExt << "\" "
+        << "type=\"image/svg+xml\" width=\"" << png_width * SVG_SCALE << "\" height=\"" << png_height * SVG_SCALE << "\" "
+        << "border=\"0\" usemap=\"#" << mapName << "\">" << endl
+        << "<param name=\"src\" value=\"" << relPath << baseName << "." << imgExt << "\">" << endl;
+      out << "<img src=\"" << relPath << baseName << "." 
+        << "png" << "\" border=\"0\" usemap=\"#"
+        << mapName << "\" alt=\"\">" << endl;
+      out << "</object>" << endl;    	
+    }
+    else
+    {
+      out << "<img src=\"" << relPath << baseName << "." 
+          << imgExt << "\" border=\"0\" usemap=\"#"
+          << mapName << "_map\" alt=\"\">";
+    }
     out << "</center>" << endl;
     QString tmpstr;
     QTextOStream tmpout(&tmpstr);
@@ -2611,6 +2692,7 @@
       QCString imgName=baseName+"."+imgExt;
       DotRunner dotRun(baseName+".dot");
       dotRun.addJob(imgExt,imgName);
+      if (imgExt == "svg") dotRun.addJob("png",baseName+".png");
       if (generateImageMap) dotRun.addJob(MAP_CMD,baseName+".map");
       if (!dotRun.run())
       {
@@ -2618,6 +2700,7 @@
         return baseName;
       }
       checkDotResult(imgName);
+      if (imgExt == "svg") checkDotResult(baseName+".png");
     }
     else if (format==EPS)
     {
@@ -2646,11 +2729,27 @@
 
   if (format==BITMAP && generateImageMap)
   {
-    out << "<p><center><img src=\"" << relPath << baseName << "." 
-        << imgExt << "\" border=\"0\" usemap=\"#"
-        << mapName << "_map\" alt=\"";
-    out << m_dir->displayName();
-    out << "\">";
+    out << "<p><center>";
+    if (imgExt == "svg")
+    {
+      unsigned png_width = 0, png_height = 0;
+    
+      getPngImageSize(NULL, baseName+".png", &png_width, &png_height);
+      out << "<object data=\"" << relPath << baseName << "." << imgExt << "\" "
+        << "type=\"image/svg+xml\" width=\"" << png_width * SVG_SCALE << "\" height=\"" << png_height * SVG_SCALE << "\" "
+        << "border=\"0\" usemap=\"#" << mapName << "\">" << endl
+        << "<param name=\"src\" value=\"" << relPath << baseName << "." << imgExt << "\">" << endl;
+      out << "<img src=\"" << relPath << baseName << "." 
+        << "png" << "\" border=\"0\" usemap=\"#"
+        << mapName << "\" alt=\"" << m_dir->displayName() << "\">" << endl;
+      out << "</object>" << endl;
+    }
+    else
+    {
+      out << "<img src=\"" << relPath << baseName << "." 
+          << imgExt << "\" border=\"0\" usemap=\"#"
+          << mapName << "_map\" alt=\"" << m_dir->displayName() << "\">";
+    }
     out << "</center>" << endl;
     QString tmpstr;
     QTextOStream tmpout(&tmpstr);
@@ -2749,12 +2848,14 @@
 
   DotRunner dotRun("graph_legend.dot");
   dotRun.addJob(imgExt,imgName);
+  if (imgExt == "svg") dotRun.addJob("png","graph_legend.png");
   if (!dotRun.run())
   {
       QDir::setCurrent(oldDir);
       return;
   }
   checkDotResult(imgName);
+  if (imgExt == "svg") checkDotResult("graph_legend.png");
   QDir::setCurrent(oldDir);
 }
   
@@ -2785,8 +2886,11 @@
   QCString imgName = (QCString)outFile+"."+imgExt;
 
   DotRunner dotRun(inFile);
-  if (format==BITMAP) 
+  if (format==BITMAP)
+  {
     dotRun.addJob(imgExt,imgName);
+    if (imgExt == "svg") dotRun.addJob("png",(QCString)outFile+".png");
+  }
   else // format==EPS
     dotRun.addJob("ps",QCString(outFile)+".eps");
   if (!dotRun.run())
@@ -2806,7 +2910,11 @@
     }
   }
 
-  if (format==BITMAP) checkDotResult(imgName);
+  if (format==BITMAP)
+  {
+  	checkDotResult(imgName);
+  	if (imgExt == "svg") checkDotResult((QCString)outFile+".png");
+  }
 
   if (env==".")
   {
@@ -2856,6 +2964,71 @@
   QDir::setCurrent(oldDir);
   return result;
 }
+
+void getPngImageSize(const char *dir, const char *file, unsigned *width, unsigned *height)
+{
+  QCString absOutFile = dir;
+  absOutFile+=portable_pathSeparator();
+  absOutFile+=file;
+
+  QCString oldDir;
+  if (dir != NULL)
+  {
+    // chdir to the output dir, so dot can find the png file.
+    oldDir = convertToQCString(QDir::currentDirPath());
+    // go to the html output directory (i.e. path)
+    QDir::setCurrent(dir);
+    //printf("Going to dir %s\n",QDir::currentDirPath().data());
+  }
+
+  FILE *fp;
+  png_structp png_ptr = NULL;
+  png_infop info_ptr = NULL;
+
+  fp = fopen(file, "rb");
+  if (!fp)
+  {
+    perror("fopen()");
+    goto error_exit;
+  }
+	
+  /* Allocate memory for png structures */
+  png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
+  if (!png_ptr) 
+  {
+    //fprintf(stderr, "%s(): png_create_read_struct() returned zero pointer.\n", __func__);
+    goto error_exit;
+  }
+
+  info_ptr = png_create_info_struct(png_ptr);
+  if (!info_ptr)
+  {
+    //fprintf(stderr, "%s(): png_create_info_struct() returned zero pointer.\n", __func__);
+    goto error_exit;
+  }
+
+  /* Give the pointer of the open file to libpng */
+  png_init_io(png_ptr, fp);
+
+  /* Read file info */
+  png_read_info(png_ptr, info_ptr);
+
+  /* Get image dimensions */
+  *width = png_get_image_width(png_ptr, info_ptr);
+  *height = png_get_image_height(png_ptr, info_ptr);
+
+error_exit:
+  if (png_ptr != NULL && info_ptr != NULL)
+    png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL);
+  else if (png_ptr != NULL)
+    png_destroy_read_struct(&png_ptr, (png_infopp)NULL, (png_infopp)NULL);
+  if (fp != NULL)
+  {
+    fclose(fp);
+    fp = NULL;	
+  }
+  if (dir != NULL) QDir::setCurrent(oldDir);
+}
 // end MDG mods
 
 //-------------------------------------------------------------
@@ -3126,6 +3299,7 @@
 
     DotRunner dotRun(baseName+".dot");
     dotRun.addJob(imgExt,imgName);
+    if (imgExt == "svg") dotRun.addJob("png",baseName+".png");
     if (writeImageMap) dotRun.addJob(MAP_CMD,mapName);
     if (!dotRun.run())
     {
@@ -3136,9 +3310,27 @@
     if (writeImageMap)
     {
       QCString mapLabel = convertNameToFile(baseName);
-      t << "<center><table><tr><td><img src=\"" << relPath << imgName
-        << "\" border=\"0\" alt=\"\" usemap=\"#" 
-        << mapLabel << "_map\">" << endl;
+      t << "<center><table><tr><td>";
+      if (imgExt == "svg")
+      {
+        unsigned png_width = 0, png_height = 0;
+    
+        getPngImageSize(NULL, baseName+".png", &png_width, &png_height);
+        t << "<object data=\"" << relPath << imgName << "\" "
+          << "type=\"image/svg+xml\" width=\"" << png_width * SVG_SCALE << "\" height=\"" << png_height * SVG_SCALE << "\" "
+          << "border=\"0\" usemap=\"#" << mapLabel << "\">" << endl
+          << "<param name=\"src\" value=\"" << relPath << imgName << "\">" << endl;
+        t << "<img src=\"" << relPath << baseName << "."
+          << "png" << "\" border=\"0\" usemap=\"#"
+          << mapLabel << "\" alt=\"\">" << endl;
+        t << "</object>" << endl;
+      }
+      else
+      {
+        t << "<img src=\"" << relPath << imgName
+          << "\" border=\"0\" alt=\"\" usemap=\"#" 
+          << mapLabel << "_map\">" << endl;
+      }
       t << "<map name=\"" << mapLabel << "_map\">" << endl;
       convertMapFile(t,mapName,relPath);
       t << "</map></td></tr></table></center>" << endl;
Index: src/dot.h
===================================================================
--- src/dot.h	(Revision 593)
+++ src/dot.h	(Arbeitskopie)
@@ -336,6 +336,6 @@
                            const char *outFile,GraphOutputFormat format);
 QString getDotImageMapFromFile(const QString& inFile, const QString& outDir,
                                const QCString& relPath,const QString &context);
+void getPngImageSize(const char *dir, const char *file, unsigned *width, unsigned *height);
 
-
 #endif
Index: src/config.l
===================================================================
--- src/config.l	(Revision 593)
+++ src/config.l	(Arbeitskopie)
@@ -1104,7 +1104,7 @@
   {
     dotImageFormat = "png";
   }
-  else if (dotImageFormat!="gif" && dotImageFormat!="png" && dotImageFormat!="jpg")
+  else if (dotImageFormat!="gif" && dotImageFormat!="png" && dotImageFormat!="jpg" && dotImageFormat!="svg")
   {
     config_err("Invalid value for DOT_IMAGE_FORMAT: `%s'. Using the default.\n",dotImageFormat.data());
     dotImageFormat = "png";
@@ -2916,11 +2916,13 @@
   ce = addEnum(
                     "DOT_IMAGE_FORMAT",
                     "The DOT_IMAGE_FORMAT tag can be used to set the image format of the images \n"
-		    "generated by dot. Possible values are png, jpg, or gif\n"
+		    "generated by dot. Possible values are png, svg, jpg, or gif\n"
+                    "If svg is selected, an additional png for browsers which doesn't support svg will be generated.\n"
                     "If left blank png will be used. \n",
                     "png"
                    );
   ce->addValue("png");
+  ce->addValue("svg");
   ce->addValue("jpg");
   ce->addValue("gif");
   ce->addDependency("HAVE_DOT");
Index: src/htmldocvisitor.cpp
===================================================================
--- src/htmldocvisitor.cpp	(Revision 593)
+++ src/htmldocvisitor.cpp	(Arbeitskopie)
@@ -29,6 +29,7 @@
 #include "parserintf.h"
 #include "msc.h"
 
+#define SVG_SCALE 1.04
 
 static const int NUM_HTML_LIST_TYPES = 4;
 static const char types[][NUM_HTML_LIST_TYPES] = {"1", "a", "i", "A"};
@@ -1161,6 +1162,7 @@
                                   const QString &context)
 {
   QString baseName=fileName;
+  QCString imgExt = Config_getEnum("DOT_IMAGE_FORMAT");
   int i;
   if ((i=baseName.findRev('/'))!=-1)
   {
@@ -1170,9 +1172,26 @@
   writeDotGraphFromFile(fileName,outDir,baseName,BITMAP);
   QString mapName = baseName+".map";
   QString mapFile = fileName+".map";
-  m_t << "<img src=\"" << relPath << baseName << "." 
-    << Config_getEnum("DOT_IMAGE_FORMAT") << "\" alt=\""
-    << baseName << "\" border=\"0\" usemap=\"#" << mapName << "\">" << endl;
+  if (imgExt == "svg")
+  {
+    unsigned png_width = 0, png_height = 0;
+    
+    getPngImageSize(outDir, baseName+".png", &png_width, &png_height);
+    m_t << "<object data=\"" << relPath << baseName << "." << imgExt << "\" " 
+      << "type=\"image/svg+xml\" width=\"" << png_width * SVG_SCALE << "\" height=\"" << png_height * SVG_SCALE << "\" "
+      << "border=\"0\" usemap=\"#" << mapName << "\">" << endl
+      << "<param name=\"src\" value=\"" << relPath << baseName << "." << imgExt << "\">" << endl;
+    m_t << "<img src=\"" << relPath << baseName << ".png" 
+      << "\" alt=\""
+      << baseName << "\" border=\"0\" usemap=\"#" << mapName << "\">" << endl;
+    m_t << "</object>" << endl;
+  }
+  else 
+  {
+    m_t << "<img src=\"" << relPath << baseName << "." 
+      << imgExt << "\" alt=\""
+      << baseName << "\" border=\"0\" usemap=\"#" << mapName << "\">" << endl;
+  }
   QString imap = getDotImageMapFromFile(fileName,outDir,relPath.data(),context);
   m_t << "<map name=\"" << mapName << "\">" << imap << "</map>" << endl;
 }
