public ImageData(OpenXmlPart contentPart, ImagePart part)
 {
     ContentType = part.ContentType;
     ContentPart = contentPart;
     using (Stream s = part.GetStream(FileMode.Open, FileAccess.Read))
     {
         Image = new byte[s.Length];
         s.Read(Image, 0, (int)s.Length);
     }
 }
 public void WriteImage(ImagePart part)
 {
     using (Stream s = part.GetStream(FileMode.Create, FileAccess.ReadWrite))
         s.Write(Image, 0, Image.GetUpperBound(0) + 1);
 }
Exemple #3
0
 public ImageData(ImagePart part)
 {
     m_ContentType = part.ContentType;
     using (Stream s = part.GetStream(FileMode.Open, FileAccess.Read))
     {
         m_Image = new byte[s.Length];
         s.Read(m_Image, 0, (int)s.Length);
     }
 }
 internal void FeedDataImagePart(ImagePart NewPart, ImagePart ExistingPart)
 {
     System.Drawing.Imaging.ImageFormat imgtype = SLTool.TranslateImageContentType(ExistingPart.ContentType);
     using (System.Drawing.Bitmap bm = new System.Drawing.Bitmap(ExistingPart.GetStream()))
     {
         using (MemoryStream ms = new MemoryStream())
         {
             bm.Save(ms, imgtype);
             ms.Position = 0;
             NewPart.FeedData(ms);
         }
     }
 }