I have the same question, but for a slightly different purpose:
I have loaded an image from a file, into a Picture object. Now I like to add a Watermark to it. As I cannot directly draw into the loaded picture (its Graphics property is nil), I have to clone it first.
But when I simply do this:
dim clone as new Picture (orig.Width, orig.Height)
clone.Graphics.DrawPicture orig, 0, 0
… then I end up with a bad copy of the picture if it’s not using the Mac’s default resolution (72 dpi). That is, on Windows, where the dpi is usually 96 instead of 72, this leads to wrongly sized files when I save or draw the clone.
So I tried this:
dim clone as new Picture (orig.Width, orig.Height)
clone.HorizontalResolution = orig.HorizontalResolution
clone.VerticalResolution = orig.VerticalResolution
clone.Graphics.DrawPicture orig, 0, 0
However, that does not help at all. Same results.
The way to make it work was rather counter-intuitive. I had to change the original picture’s dpi to 72, then clone it, then restore its original dpi:
dim oh as integer = orig.HorizontalResolution
dim ov as integer = orig.VerticalResolution
orig.HorizontalResolution = 72
orig.VerticalResolution = 72
dim clone as new Picture (orig.Width, orig.Height)
clone.HorizontalResolution = orig.HorizontalResolution
clone.VerticalResolution = orig.VerticalResolution
clone.Graphics.DrawPicture orig, 0, 0
orig.HorizontalResolution = oh
orig.VerticalResolution = ov
clone.HorizontalResolution = oh
clone.VerticalResolution = ov
Is that really the indended behavior? Or is this a bug? It happens the same wrong way on Mac and Windows unless I do what’s shown in the last code example above.
I’d expect that the docs would provide an example for how to properly clone a Picture that I can modify but I could not find one.