[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.drawing

Metafile from memory stream doesn't work, file stream does???

Bret Pehrson

12/2/2004 8:58:00 PM

I have the following requirement: copy a graph image to the clipboard. The
graph control supports a SaveAsImage method that will copy the image in a
metafile format to the specified stream.

If I use a file stream, everything works as expected, however I have to persist
to file, read back in, and then copy to the clipboard, which seems pretty
backwards to me.

private void CopyViaFileStream()
{
string tempFile = Path.GetTempFileName();
FileStream stream = new FileStream(tempFile, FileMode.Create);
graph.SaveAsImage(stream, ImageFormat.Emf);
stream.Close();
Metafile mf = new Metafile(tempFile);
ClipboardMetafileHelper.PutEnhMetafileOnClipboard(this.Handle, mf);
File.Delete(tempFile);
}


However, if I use a memory stream, it dies on the construction of the metafile
from the memory stream w/ a "A generic error occurred in GDI+" exception:

private void CopyViaMemoryStream()
{
MemoryStream stream = new MemoryStream();
graph.SaveAsImage(stream, ImageFormat.Emf);
Metafile mf = new Metafile(stream); // A generic error occurred in GDI+
ClipboardMetafileHelper.PutEnhMetafileOnClipboard(this.Handle, mf);
}


Anyone have any comments on how to get the via memory stream method to work?

(The ClipboardMetafileHelper.PutEnhMetafileOnClipboard method converts from the
(incompatible!!!) .Net metafile format to the traditional (supported) metafile
format.)
2 Answers

mcl2

8/29/2011 9:40:00 PM

0

On Aug 25, 2:55 pm, Car Crashes Mean Car Sales - GM loves highway
criminals <beta...@earthlink.net> wrote:
> On Aug 25, 12:07 pm, Mick <m...@pitt.edu> wrote:
>
> > Rescuer of kidnapped girl comes forward as undocumented immigrant
>
> >http://www.cnn.com/2011/US/08/19/new.mexico.kidnapping/inde......
>
> story is a hoax.

Is it? You have some references for that?

Or are you just working with your fevered imagination?

Lots of documentation it's real

http://latimesblogs.latimes.com/nationnow/2011/08/new-mexico-illegal-immigration-susana-martinez-antonio-diaz-c...

http://abclocal.go.com/kabc/story?section=news/national_world&...

http://abclocal.go.com/kabc/story?section=news/national_world&...

Ramon F Herrera

8/29/2011 9:56:00 PM

0

On Aug 25, 1:55 pm, Car Crashes Mean Car Sales - GM loves highway
criminals <beta...@earthlink.net> wrote:
> On Aug 25, 12:07 pm, Mick <m...@pitt.edu> wrote:
>
> > Rescuer of kidnapped girl comes forward as undocumented immigrant
>
> >http://www.cnn.com/2011/US/08/19/new.mexico.kidnapping/inde......
>
> story is a hoax.

When you were a little girl, you were lied a lot to, correcto?

-Ramon