0

I'm getting some images from my database and populating a ppt file with them like this:

foreach (DataRow item in imagens.Rows)
      {
                    nomeArquivo = item[0].ToString();
                    imagebytes = (byte[])item[1];
                    extensao = item[2].ToString();

                    MemoryStream ms = new MemoryStream(imagebytes);
                    img = Image.FromStream(ms);
                    img.Save(nomeArquivo + ".png", ImageFormat.Png);

                    slideAdd = slides.Add(indice, PowerPoint.PpSlideLayout.ppLayoutPictureWithCaption);//no objeto de slides, vou criar um no índice especificado - começa a partir de 1
                    shape = slideAdd.Shapes[2];
                    string caminho = Path.Combine(executableLocation, nomeArquivo + ".png");
                    slideAdd.Shapes.AddPicture2(caminho, MsoTriState.msoFalse, MsoTriState.msoTrue, shape.Left, shape.Top, shape.Width, shape.Height, MsoPictureCompress.msoPictureCompressFalse);
                    slideAdd.Shapes[1].TextFrame.TextRange.Text = nomeArquivo;
                    slideAdd.Shapes[3].TextFrame.TextRange.Text = nomeArquivo;
                    indice++;
                }

However, they are not resized to fit the containg shape:

enter image description here

Is there a way to resize them beforehand?

Community
  • 1
  • 1
Joao Victor
  • 1,111
  • 4
  • 19
  • 39
  • Possible duplicate of [Resize an Image C#](https://stackoverflow.com/questions/1922040/resize-an-image-c-sharp) –  Aug 17 '17 at 19:58
  • Possible duplicate of [Resize image proportionally](https://stackoverflow.com/questions/6501797/resize-image-proportionally-with-maxheight-and-maxwidth-constraints) –  Aug 17 '17 at 19:58

0 Answers0