7

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!

Frank Krueger
  • 64,851
  • 44
  • 155
  • 203
  • 2
    GDI never supported EPS, however, there were flavors of EPS that contained WMF previews. http://en.wikipedia.org/wiki/Encapsulated_PostScript#EPS_previews Maybe that's what you have been remembering... – oefe Feb 21 '10 at 10:05

3 Answers3

2

You can use GhostScript to produce images from an EPS. Once you have an image you can then display that within your application.

Mark Redman
  • 22,537
  • 19
  • 88
  • 134
  • 5
    Hi Mark, it's customary in [so] answers to include a summary of the contents or the highlights that specifically answer the question. The goal of SE sites is to become a resource of knowledge, of answers, for years to come. With a email-me-only answer, we have to send you a personal email requesting code that we might not even be sure about. Most importantly, if your email changes or you win the lotto, your answer is useless for anyone who visits this page in the future. Consider making an edit to your answer and posting the code here. Good luck! – Jeremy Thompson May 01 '13 at 00:13
2

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
  • 6,285
  • 18
  • 27
  • None of these can convert from eps to jpg. At least not on my machine :-( – Thomas Eyde Apr 14 '10 at 10:10
  • ImageMagick should be able to convert eps to jpg, however it will require the additional use of GhostScript, ImageMagick uses Ghostscript internally for PDF processing, I assume it also suppprts EPS in the same way? – Mark Redman May 01 '13 at 11:34
  • Yes ImageMagick does support EPS, just checked: Have a look at this answer: http://stackoverflow.com/questions/7583821/how-to-convert-a-eps-file-to-a-high-quality-1024x1024-jpg – Mark Redman May 02 '13 at 09:24
1

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
  • 4,997
  • 32
  • 55