Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Graphs to clipboard as vector graphics...

Dear People

The built-in ToClipboard() function of the Graph controls copy a bitmap to the clipboard. Now I would like to improve the quality of the clipboard image by placing a metafile into the clipboard (vector graphics).

Do you have any good ideas how I can do it?

Thank you and best regards,
Ilkka

0 Kudos
Message 1 of 9
(6,825 Views)
Dear Ilkka

I don't think there's a reasonable way of editing the image data present
in the clipboard; I'd rather save the data to a file and edit it there.

Best regards

Philipp Roessler
0 Kudos
Message 2 of 9
(6,767 Views)

Hi Philipp,

 

Yes, this is important! I am making commercial software which is sold as a standalone product or with some measurement equipments.

 

The metafile-clipboard is surely possible to make...? Here is an example from an other great graph control:

 

http://zedgraph.org/wiki/index.php?title=Improve_Clipboard_Image_Quality

 

You can see the difference when you copy the graphs into MS Word or somewhere else and try to resize those...

 

Best regards,
Ilkka

Message Edited by Ilkka on 06-26-2007 10:30 PM

0 Kudos
Message 3 of 9
(6,754 Views)
Dear Ilkka

After digging around in "Metafile" I realized that what you actually want
to do is convert a BMP (which you get from 'ToString ()' or 'ToImage ()')
into a WMF or EMF image, right!?

This sort of thing isn't specific to Measurement Studio and I've never
done it, but I know that the .NET framework gives you all that's required
(e.g. the 'Metafile' class), moreover you probably can even find a
ready-made conversion class/method somewhere on the web.

Best regards

Philipp Roessler
0 Kudos
Message 4 of 9
(6,721 Views)

Hello Philipp,

 

I would like to draw the plots direct into a metafile without a bitmap conversion. Similar way as screen drawing and printing works… But this is not so urgent.. let’s see if we found something…

 

Thanks for your interest and have a nice day,
Ilkka

0 Kudos
Message 5 of 9
(6,718 Views)

Hello Philipp,

I played a little with my old trial and it started to work after one change!! Robot Happy

Cheers,
Ilkka

PS: Here is the source code.

    public override void Copy()

    {

        Graphics g = _scatterGraph.CreateGraphics();

        IntPtr hdc = g.GetHdc();

        Metafile metaFile = new Metafile(hdc, EmfType.EmfOnly);

        g.ReleaseHdc(hdc);

        g.Dispose();

 

        Graphics gMeta = Graphics.FromImage(metaFile);

 

        GraphicsUnit unit = GraphicsUnit.Pixel;

        RectangleF recF = metaFile.GetBounds(ref unit);

        ComponentDrawArgs cda = new ComponentDrawArgs(gMeta, _scatterGraph.Bounds);

        

        _scatterGraph.Draw(cda);

        gMeta.Dispose();

       

        // This function can be found from my previous post.

        ClipboardMetafileHelper.PutEnhMetafileOnClipboard(this.Handle, metaFile);

                                                                                 

    }

Message Edited by Ilkka on 06-27-2007 05:39 PM

0 Kudos
Message 6 of 9
(6,713 Views)
 Sorry, there were some extra lines in the previous post. Here is a better source:
 

    public override void Copy()

    {

        Graphics g = _scatterGraph.CreateGraphics();

        IntPtr hdc = g.GetHdc();

        Metafile metaFile = new Metafile(hdc, EmfType.EmfOnly);

        g.ReleaseHdc(hdc);

        g.Dispose();

 

        Graphics gMeta = Graphics.FromImage(metaFile);

        ComponentDrawArgs cda = new ComponentDrawArgs(gMeta, _scatterGraph.Bounds);

        

        _scatterGraph.Draw(cda);

        gMeta.Dispose();

       

        // This function can be found from my previous post.

        ClipboardMetafileHelper.PutEnhMetafileOnClipboard(this.Handle, metaFile);

                                                                                 

    }

 

BR,
Ilkka

0 Kudos
Message 7 of 9
(6,705 Views)
Dear Ilkka
 
Now, this is what I call a straightforward solution. Thanks for sharing!
 
Philipp Roessler
 
0 Kudos
Message 8 of 9
(6,681 Views)

Thanks a lot you save me a lot of time.

 

Great code !

 

Smiley Happy

0 Kudos
Message 9 of 9
(4,905 Views)