jinksk1957
asked on
In C#.NET, how can I anti-alias an image object.
In C#.NET, how can I anti-alias an image object and copy it to the clipboard so that the target app (Word) recognizes the anti-aliasing of the lines?
I have a diagraming application that allows a user to create a polar grid diagram use to plot wind envelopes. I am using the Syncfusion Diagraming control for Windows Forms that allows you to export the diagram's content to an image object. However, there seems to be no way to preserve the anti-aliasing of the original diagram when the image object is sent through the Clipboard to Microsoft Word.
Am I doing something wrong or is this impossible? I have seen other software do this: Visio to Word, et.al.
I have a diagraming application that allows a user to create a polar grid diagram use to plot wind envelopes. I am using the Syncfusion Diagraming control for Windows Forms that allows you to export the diagram's content to an image object. However, there seems to be no way to preserve the anti-aliasing of the original diagram when the image object is sent through the Clipboard to Microsoft Word.
Am I doing something wrong or is this impossible? I have seen other software do this: Visio to Word, et.al.
Apparently, there is support for EMF files, too.
http://msdn.microsoft.com/en-us/library/system.drawing.imaging.imageformat_members.aspx
http://msdn.microsoft.com/en-us/library/system.drawing.imaging.imageformat_members.aspx
ASKER
jimbobmcgee;
Your answer looks promising; however, I can't get directly at the underlying Graphics object of the Diagram control. They do provide two export (to memory) methods:
ExportDiagramAsImage(bool respectBounds)
ExportDiagramAsGraphics(Gr aphics gfx)
I can easily find the Clipboard.SetImage(Image image) method to copy as an image; however, there is no equivalent Clipboard.SetGraphics(Grap hics gfx) method. Do I use Clipboard.SetDataObject() instead?
Your answer looks promising; however, I can't get directly at the underlying Graphics object of the Diagram control. They do provide two export (to memory) methods:
ExportDiagramAsImage(bool respectBounds)
ExportDiagramAsGraphics(Gr
I can easily find the Clipboard.SetImage(Image image) method to copy as an image; however, there is no equivalent Clipboard.SetGraphics(Grap
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Otherwise, you are just going to have to use a significantly bigger width/height combo and let Word resize it down. It will always look better sizing a large image down than a small image up.
J.
J.
ASKER
Thanks jimbob! That works great. Now I've just got to figure out how to just get what I want from their Diagram control to copy and not the whole page. Thanks again for the help
bmp.Save(myStream, ImageFormat.Wmf);
Otherwise, if you can access the underlying Graphics object used to draw the chart to the image, you may be able to use:
gfx.SmoothingMode = SmoothingMode.AntiAlias;
Otherwise, you just have to create the image in as large a resolution as you dare and let the target app treat it as it chooses. If you try to display it in an area smaller than the image data, Word should resize it nicely enough. If you try to display it in an area larger than the image data, it will start to look blocky.
J.