views:

600

answers:

3

Is it possible to load and display EPS file using plain WinForms GDI+? If not, is there a free library to help out?

I seem to remember that Windows GDI supported EPS files, but after Googling around a bit, I am starting to doubt that memory.

All I want to do is load the file and draw it using a Graphics context.

I am aware that I can just use any program to convert the file to PNG or something and render it that way, but because I am trying to render at multiple resolutions, I would prefer to keep the vector data in the EPS file.

Thanks!

+1  A: 

You can use GhostScript to produce images from an EPS.

If you email me (see my profile for email address) I can send you a c# wrapper for the GhostScript dll that can convert PDF/PS and EPS to jpg and other image formats.

HTH

Mark Redman
+1  A: 

In your question you indicated you want the output in a vector format which would preclude bitmaps, jpeg etc. Here are a couple of ways of getting a XAML file which is a vector file with extensive support by Microsoft.

Microsoft Expression Blend 3 and Design 3 can both open .ai (eps) files and convert them to vector formats, design and XAML respectively, so it is definitely possible.

I know it is relatively easy to automate most Microsoft Office applications like Word and Excel, but I have not seen any documented com inter-op assemblies for these Expression products.

Perhaps you can use the converters that are part of Expression in an undocumented way?

If that doesn't work here is plan B:

Here is a free converter that will convert .ai (eps) files to XAML. To use it you need Adobe Illustrator however.

JonnyBoats
+1  A: 

All the free or open source libraries I know that can convert EPS to other vector or raster format are all based on Ghostscript. You can invoke ghostscript directly, with wrapper provided or alternatively look at imagemagick. It is a very popular library for manipulating image graphics and has been around for a long time. It also internally relies on Ghostscript for handling EPS format. There is a .NET wrapper for it that you can find at http://imagemagick.codeplex.com/. You can read a bit about its background here too http://www.codeproject.com/KB/dotnet/ImageMagick_in_VBNET.aspx. There is also pstoedit that is also based on ghostscript to read EPS and allow export to format like WMF. You will need to the call to pstoedit API using interop in .NET

Besides Ghostscript there are several commercial products that I known of like ImageGear and LeadTools which will let you take EPS to almost any other kind of graphic formats.

Fadrian Sudaman
None of these can convert from eps to jpg. At least not on my machine :-(
Thomas Eyde