title: Open xml getting images from .pptx file
body: <p>I have a Windows forms app in .Net 4.0. I work in C#.
  I want to grab an image from a given slide in a .pptx file.</p>
  
  <p>This code gets every image on the slide:</p>
  
  <pre><code> public static SlidePart GetSlidePart(PresentationDocument presentationDocument, int slideIndex)
      {
          if (presentationDocument == null)
          {
              throw new ArgumentNullException("presentationDocument", "GetSlidePart Method: parameter presentationDocument is null");
          }
  
          int slidesCount = CountSlides(presentationDocument);
  
          if (slideIndex &lt; 0 || slideIndex &gt;= slidesCount)
          {
              throw new ArgumentOutOfRangeException("slideIndex", "GetSlidePart Method: parameter slideIndex is out of range");
          }
  
          PresentationPart presentationPart = presentationDocument.PresentationPart;
  
          if (presentationPart != null &amp;&amp; presentationPart.Presentation != null)
          {
              Presentation presentation = presentationPart.Presentation;
  
              if (presentation.SlideIdList != null)
              {
                  var slideIds = presentation.SlideIdList.ChildElements;
  
                  if (slideIndex &lt; slideIds.Count)
                  {
                      string slidePartRelationshipId = (slideIds[slideIndex] as SlideId).RelationshipId;
  
                      SlidePart slidePart = (SlidePart)presentationPart.GetPartById(slidePartRelationshipId);
  
                      return slidePart;
                  }
              }
          }
  
          return null;// No slide found
      }
  </code></pre>
  
  <p>But, how to convert slidePart to an image which will be shown in my Windows form (in imageList or something similar)?</p>