Metafile & Graphics

M

Marco Rego

I have a Metafile and a Graphics attached to it and I do several drawings on
the Metafile through the Graphics. After the drawings I need to print the
metafile.
If I try to print the Metafile right away, nothing shows on the page, now,
If I do a Graphics.Dispose() and then print the Metafile, it works without
any problem.

My problem is that after printing the Metafile I still need to work on it
through the Graphics, but if I try to reinitializate the Graphics object with
a call of Graphics.FromImage(metafile), I get a "out of memory" error.

Is there a different way to create a Graphics from a Metafile ?
Is it possible to have access to a Metafile which is attached to a Graphics,
without having to dispose the Graphics ?

Thanks for any help.

______
Marco
 
P

Peter Duniho

[...]
Is there a different way to create a Graphics from a Metafile ?
Is it possible to have access to a Metafile which is attached to a
Graphics,
without having to dispose the Graphics ?

I'm no expert on the use of metafiles in .NET. However, I think it's
useful to keep in mind that a metafile is as much a recorder of API calls
as it is an image object. It's not surprising to me that you would have
to explicitly finish your recording before you can play back the
recording, and it's only slightly less surprising to me that you can't
start recording again into a metafile that you've already finished
recording.

Either operation _could_ have been supported, but it's not difficult to
see why they might not be.

If there is a way to do exactly what you're asking, you'll likely find the
path by going through the unmanaged metafile documentation. Learning how
the unmanaged Win32 API deals with metafiles may help you discover some
technique that can be applied to the managed version. I don't have the
specific details you're asking about, but that's where I'd look for them
if I were you.

That said, why not just create a new metafile and start out by drawing the
previously-created one into it? Then draw whatever else you want to add.

Pete
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top