06-15-2007 11:36 AM
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
06-26-2007 04:42 AM
06-26-2007 03:25 PM - edited 06-26-2007 03:25 PM
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
06-27-2007 07:17 AM
06-27-2007 09:44 AM
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
06-27-2007 10:37 AM - edited 06-27-2007 10:37 AM
Hello Philipp,
I played a little with my old trial and it started to work after one change!!
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
06-27-2007 02:18 PM
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
06-28-2007 03:23 AM
01-28-2011 10:44 AM
Thanks a lot you save me a lot of time.
Great code !