How to load EPS files and draw them using WinForms
Asked Answered
G

3

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!

Galoot answered 7/10, 2009 at 20:0 Comment(1)
GDI never supported EPS, however, there were flavors of EPS that contained WMF previews. en.wikipedia.org/wiki/Encapsulated_PostScript#EPS_previews Maybe that's what you have been remembering...Just
H
2

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

Hemicellulose answered 7/10, 2009 at 20:19 Comment(1)
Hi Mark, it's customary in Stack Overflow 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!Footman
J
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.

Jello answered 28/2, 2010 at 10:7 Comment(3)
None of these can convert from eps to jpg. At least not on my machine :-(Poi
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?Hemicellulose
Yes ImageMagick does support EPS, just checked: Have a look at this answer: #7584321Hemicellulose
C
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.

Crater answered 26/2, 2010 at 19:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.