SaveSubgraphImage
(
Bitmap oBitmap,
String sFolder,
String sVertexName,
CreateSubgraphImagesAsyncArgs oCreateSubgraphImagesAsyncArgs
)
{
Debug.Assert(oBitmap != null);
Debug.Assert( !String.IsNullOrEmpty(sFolder) );
Debug.Assert( !String.IsNullOrEmpty(sVertexName) );
Debug.Assert(oCreateSubgraphImagesAsyncArgs != null);
AssertValid();
ImageFormat eImageFormat = oCreateSubgraphImagesAsyncArgs.ImageFormat;
// The "Img-" prefix is to prevent a vertex name like "con" or "lpt"
// from causing the following exception when
// System.Drawing.Image.Save() is called:
//
// [ExternalException]: A generic error occurred in GDI+.
//
// The exception occurs because "con" (console), "lpt" (line printer)
// and some other names are reserved file names in Windows.
String sFileNameNoPath = String.Format(
"Img-{0}.{1}"
,
FileUtil.EncodeIllegalFileNameChars(sVertexName),
SaveableImageFormats.GetFileExtension(eImageFormat)
);
String sFileNameWithPath = Path.Combine(sFolder, sFileNameNoPath);
SaveBitmap(oBitmap, sFileNameWithPath, eImageFormat);
return (sFileNameNoPath);
}