Why does this image set conversion result in an InvalidArgumentException?

I have the following method I wanted to use for creating image sets from one picture:

Public Function makeImageSet(p as picture, width as integer, height as integer) as Picture Dim pictures() As Picture For q As Integer = 1 To 3 Dim scale As Double = min(width / p.Width, height / p.Height) Dim p1 As New Picture(p.width * scale, p.height * scale) p1.VerticalResolution = 72 * q p1.HorizontalResolution = 72 * q Dim g As Graphics = p1.Graphics g.AntiAliasMode = Graphics.AntiAliasModes.HighQuality g.DrawPicture p, 0, 0, p1.Width, p1.Height, 0, 0, p.Width, p.Height Pictures.Append p1 Next Return New Picture(width, height, Pictures) End Function

The code runs so far, but the Return line provokes an invalid argument exception: “Pictures must have the same aspect ratio”. They do by having the same width and height, and their resolutions are 72, 144 and 216 dpi. So how come they are not compatible?

Silly me. The end ratio can be changed, so the last line has to be

 Return New Picture(pictures(0).width, pictures(0).height, Pictures)