What am I doing wrong- or is it a bug

Hi Again Alexy

What am I doing wrong below.
I am trying to get the size of the image so I can place it correctly on the page.
However I get errors on the lines marked **
The error is
"System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index"

I know it is finding the image because if i comment out the ** lines & put values into the last line as shown the image is placed into the powerpiont file.

Version 1.7.6.0

Any help would be appreciated

Thanks

Garry


-------------------------------

Dim gtmain As Slide = pres.MainMaster

Dim pic1 As Picture = New Picture(pres, MapPath(".") + “” + (ImageLogo.ImageUrl))

Dim picid1 As Int32 = pres.Pictures.Add(pic1)

**Dim pictureWidth As Int32 = pres.Pictures(picid1 - 1).Image.Width

**Dim pictureHeight As Int32 = pres.Pictures(picid1 - 1).Image.Height

Dim slideWidth As Int32 = gtmain.Background.Width

Dim slideHeight As Int32 = gtmain.Background.Height

Dim slides As slides = pres.Slides

Dim pf As PictureFrame = gtmain.Shapes.AddPictureFrame(picid1, 2500, 100, 600, 400)

------------------------

Dear Garry,

Please try this code:

Dim picid As Int32 = pres.Pictures.Add(New Picture(pres, MapPath(".") + “” + ImageLogo.ImageUrl))
Dim pic1 As Picture = pres.Pictures.GetPictureById(picid)
Dim pictureWidth As Int32 = pic1.Image.Width
Dim pictureHeight As Int32 = pic1.Image.Height

Thanks Alexey

That fixed it.

Great support

Thanks again

Garry