Hi,
I have a situation where I may want to add the same picture multiple times to a slides document. In my example I have two images 'img1' and 'img2'. I create 4 pictures and add them one at a time in the order 'img1', 'img2', 'img1' and 'img2'. However in my output I get 'img1', 'img2', 'img1' and 'img1'. I noticed when adding the pictures to the Presentation, it does not add duplicate pictures. However, when I try to find the picture Id, if it was the 3rd or 4th picture added, it returns 'img1' which was the first image added.
Stepping through code it appears that the picture assumes it is the first in the list unless a new picture is added, then the id is updated. Is this the expected behaviour or should the same picture be allowed to be added multiple times?
If this is the expected behaviour, is there any way I can interate through Presentation.Pictures and see if the picture I am trying to add is already in use so I can get the Picture.PictureId of the picture?
I have included my source code.
Thanks
Presentation presentation = new Presentation();
Slide slide = presentation.Slides[0];
string img1 = "img1.bmp";
string img2 = "img2.bmp";
Picture picture = new Picture(presentation, img1);
presentation.Pictures.Add(picture);
slide.Shapes.AddPictureFrame(picture.PictureId, 100, 100, 500, 500);
picture = new Picture(presentation, img2);
presentation.Pictures.Add(picture);
slide.Shapes.AddPictureFrame(picture.PictureId, 100, 650, 500, 500);
picture = new Picture(presentation, img1);
presentation.Pictures.Add(picture);
slide.Shapes.AddPictureFrame(picture.PictureId, 100, 1200, 500, 500);
picture = new Picture(presentation, img2);
presentation.Pictures.Add(picture);
slide.Shapes.AddPictureFrame(picture.PictureId, 100, 1750, 500, 500);
presentation.Write("test.ppt");