I have a .NET Windows.Forms diagram editor that can export its diagrams as bitmaps. It also comes with a command line utility that just converts diagrams to bitmap images.
I don't want to scale the diagram to a given bitmap size; instead, I want to size the bitmap based on the diagram's bounding box.
I can easily determine it after drawing it (see Calculate the bounding box of a GDI+ drawing) but that is too late. I'd like to "dry draw" the image on some Graphics object of unconstrained size (perhaps a Metafile?), calculate the resulting bounding box, and use it to allocate the Bitmap.
How can I do this?