title: InkPicture control - How to save both ink and image to an image file
body: <p>I've seen articles demonstrating that the ink can be saved with the background image so that the ink is overlayed onto the image and then saved as a single image file.  But, unfortunately the articles I've seen don't go into any detail about how it is done.
  I can save the background image easy enough with the following statement:</p>
  
  <pre><code>axInkPicture1.Picture.Save(@"\path\to\file.gif");
  </code></pre>
  
  <p>...but there is no ink overlayed onto the background image</p>
  
  <p>I don't know of any direct method to save the ink, but this is how I am currently doing it:</p>
  
  <pre><code>string tempPath = Path.GetTempPath();
  string tempFile = tempPath + @"\file.gif";
  // save to a temp file
  if (axInkPicture1.Ink.Strokes.Count &gt; 0)
      {
          byte[] bytes = (byte[])axInkPicture1.Ink.Save(InkPersistenceFormat.IPF_GIF, InkPersistenceCompressionMode.IPCM_Default);
  
          using (MemoryStream ms = new MemoryStream(bytes))
          {
              using (Bitmap gif = new Bitmap(ms))
              {
                  gif.Save(tempFile);
              }
          }
  
      }
  </code></pre>
  
  <p>This saves the ink, but there is no background image.</p>
  
  <p>How do I save both the ink and image into a single file?</p>
  
  <p>Any help or direction pointing is appreciated...</p>
  
  ### EDIT
  
  <p>Here is what else I have tried so far</p>
  
  <pre><code> InkRectangle inkBox = axInkPicture1.Ink.GetBoundingBox();
          byte[] gifbits = (byte[])axInkPicture1.Ink.Save(InkPersistenceFormat.IPF_GIF, InkPersistenceCompressionMode.IPCM_Default);
          using (System.IO.MemoryStream buffer = new System.IO.MemoryStream(gifbits))
          using (var inkImage = new Bitmap(buffer))
          using (var picture = new Bitmap(axInkPicture1.Picture))
          using (var g = Graphics.FromImage(picture))
          {
              g.DrawImage(inkImage, new Rectangle(inkBox.Left, inkBox.Right, axInkPicture1.Picture.Width, axInkPicture1.Height));
              picture.Save(tempFile, System.Drawing.Imaging.ImageFormat.Gif);
          }
  </code></pre>
  
  <p>...but I'm still not having any luck.  This saves only the background picture and not the ink.  Any ideas what I'm doing wrong?</p>
  
  <p>Thanks in advance</p>