private static KeyValuePair<Range, Content> ProcessInlineShape( InlineShape _shape )
 {
     float width = _shape.Width;
      float height = _shape.Height;
      string altText = "";
      string title = "";
      try
      {
     float scaleWidth = _shape.ScaleWidth;
     if ( scaleWidth > 0.0 )
     {
        //width *= (scaleWidth / 100.0f);
     }
      }
      catch
      {
      }
      try
      {
     float scaleHeight = _shape.ScaleHeight;
     if ( scaleHeight > 0.0 )
     {
        //height *= (scaleHeight / 100.0f);
     }
      }
      catch
      {
      }
      try
      {
     altText = _shape.AlternativeText;
      }
      catch
      {
      }
      try
      {
     title = _shape.Title;
      }
      catch
      {
      }
      PngImageContent imageContent = null;
      _shape.Range.CopyAsPicture();
      object pngData = Clipboard.GetData( "PNG" );
      if ( pngData is System.IO.MemoryStream )
      {
     imageContent = new PngImageContent( (System.IO.MemoryStream) pngData, altText, title, width, height );
      }
      else
      {
     if ( Clipboard.ContainsData( DataFormats.EnhancedMetafile ) )
     {
        if ( ClipboardFunctions.OpenClipboard( IntPtr.Zero ) )
        {
           width *= 1.5f;
           height *= 1.5f;
           IntPtr data = ClipboardFunctions.GetClipboardData( DataFormats.GetFormat( DataFormats.EnhancedMetafile ).Id );
           System.Drawing.Imaging.Metafile metaFile = new System.Drawing.Imaging.Metafile( data, true );
           ClipboardFunctions.CloseClipboard();
           System.Drawing.Bitmap pngImage = new System.Drawing.Bitmap( (int) width, (int) height );
           using ( System.Drawing.Graphics g = System.Drawing.Graphics.FromImage( pngImage ) )
           {
              g.DrawImage( metaFile, new System.Drawing.Rectangle( 0, 0, (int) width, (int) height ) );
           }
           metaFile.Dispose();
           System.IO.MemoryStream pngDataStream = new System.IO.MemoryStream();
           pngImage.Save( pngDataStream, System.Drawing.Imaging.ImageFormat.Png );
           pngDataStream.Seek( 0, System.IO.SeekOrigin.Begin );
           imageContent = new PngImageContent( pngDataStream, altText, title, width, height );
           pngImage.Dispose();
        }
     }
      }
      Clipboard.Clear();
      if ( imageContent == null )
      {
     return new KeyValuePair<Range, Content>( _shape.Range, new TextContent( String.Format( "INTERNAL ERROR: Could not convert shape to PNG image." ), Edward.ERROR_STYLE ) );
      }
      else
      {
     return new KeyValuePair<Range, Content>( _shape.Range, imageContent );
      }
 }
 private string SaveImage( PngImageContent _image )
 {
     string imageDir = Path.Combine( BaseDirectory, "images" );
      if ( !Directory.Exists( imageDir ) )
      {
     Directory.CreateDirectory( imageDir );
      }
      int imageIndex = m_nextImageIndex++;
      string imageFilename = String.Format( "image{0:000000}.png", imageIndex );
      string fullImageFilename = Path.Combine( imageDir, imageFilename );
      using ( FileStream stream = new FileStream( fullImageFilename, FileMode.Create ) )
      {
     _image.Write( stream );
      }
      return "images/" + imageFilename;
 }