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!
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.
You can use GhostScript to produce images from an EPS. Once you have an image you can then display that within your application.
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.
Related
I have a Photoshop Document with a few layers that I can turn on and off to make the image display different data. Is it possible to place this image in a WPF page and use C# to turn on and off layers? I've been googling for a little while but there doesn't seem to be much information on this subject. I read that you might be able to use Expression Blend to do this, however I do not have any experience using it.
Any help would be greatly appreciated, thanks!
(Disclaimer: I'm a software engineer at Microsoft, I used to work on Expression Blend)
In short, no. There is no built-in support for loading Photoshop files in the .NET Framework nor WPF (this is despite Blend's support for loading PSD documents into a project - it has its own code for this - and it doesn't support all of the features present in the PSD file format either).
If you want to load a PSD file into your own program you'll need a PSD file reader - either write your own (a fool's errand considering how complicated the file format is) or obtain/license an existing library, there are open-source implementations available (see Paint.NET's).
A problem with PSD files is that individual layers are not necessarily simple rasters by themselves, and PSD documents don't always contain a full-resolution composite either. Consider effects-layers (Brightness, Levels, etc) or layer-effects (Outer Glow, Gradient Overlay, etc).
I suggest instead having Photoshop (via an Action or a Droplet program) convert your PSD's layers to individual PNG files (after applying any effects) and then loading those into your program and displaying them according to your requirements.
I have a list of Bitmaps, how can I convert it to avi file using c#.net. Or how can we convert a set of images to video file ?
I do not need AVI to "Set of images", but I need "Set of Images" to AVI.
i used avifile wrapper in the past, work nicely
I think you need to use third party libraries
There is AVI File Wrapper or you can use ffmpeg in .NET.
Old question, but I have two tips to achieve it. We're now 2013, but all answers are good from 2004 to 2013. These answers are useful as it seems programmers rarely take the time to work on new encoders solution, and we often rely on the same old DLL and wrappers.
Images to MPEG-1
Based on this code, http://www.codeproject.com/Articles/5834/A-C-MPEG1-Image-Compression-Class, you can write a C# Images to MPEG-1 class compatible on any platform using C#.
Images to AVI
Convert just an image with 24 bits color (try to use a gradient generator to have the maximum number of colors) to a full frame AVI using ffmpeg. Take an hexadecimal editor, check how the header of the AVI is, and how the single image has been placed in the AVI. Now do it with two images. Check the header. Refer to the specification to know which value use in the header. You'll see you can easily build a Images to AVI from scratch without any wrapper, and use it on any platform.
Both are codes from scratch.
You can check out a simple library for writing AVI files that I've coded to use in my projects.
https://sharpavi.codeplex.com/
The sources include a sample screencast app which can be easily adapted to get the bitmaps from files if you need it.
I am planning to write an app that can open and display PDF documents, and perform OCR on vector graphic elements within the PDFs. The user must be able to select regions of the document and I need to draw real-time annotations on the document. I don't need to alter or save the document itself.
I have plenty of experience with C# and WPF; I have written a similar application already that does the above on XPS/XAML documents rather than PDF. However that app only runs on Windows and PDF documents must be converted to XPS first.
I have done quite a bit of research and there are many, many options available, none of which seem an obvious choice. There are many libraries that can open PDFs or create PDFs, but most don't seem to give you access to individual vector graphic elements in a format that lets you draw/manipulate them on the screen (similar to what I could do with WPF graphic elements extracted from XPS documents).
I am familiar with .Net and C# (including .Net 2 GDI+ graphics) and I am very keen to stick to what I know. I am also using EmguCV for image recognition which can be compiled in Mono or .Net. As such I am looking at Silverlight (running standalone) or Mono options, both of which should run on PC and Mac.
Performance (for both graphics and number crunching) is a strong consideration, though I am just as interested in getting this up and running quickly.
Does anyone have any experience with opening PDFs, extracting vector graphic elements (perhaps as SVG) and rendering them in a Mono app? Can individual elements be rendered to bitmap?
Alternatively, does anyone have experience with opening PDFs in Silverlight and converting them to XPS or XAML at runtime? I know that WPF and Silverlight graphics libraries are not 1:1, but I'm not sure how this affects XPS contents (generally composed of Canvas, Glyphs and StreamGeometry objects).
Thank you for any advice, tips or links you have to share.
look at this
http://silverpdf.codeplex.com/
it's client side pdf reading library. actually right now it can only read files, but you could play with it and make your own "display" functionality.
You might want to examine the internals of your PDFs so you understand what they actually contain better - you might be very surprised! For example, text can often be scanned pages or images and vecotr graphics do not exist as neat little packages. We wrote a whole load of general articles about what is inside a PDF and analysis tools at http://www.jpedal.org/PDFblog which are not specific to any tool or language.
I need to create a program that reads tif files from a directory and then trims the bottom inch of the file and resaves the file. I know how to open the files but how would I automate this process from c#?
If you need to handle TIFF images in C# then have a look at LibTIFF.Net
http://bitmiracle.com/libtiff/ - It is open source and Native .NET component and free for commercial use.
This library should also have the TIFF cropping functions you need. I am not sure if the native .NET libraries can handle all of the TIFF functions you may require whereas LibTIFF will.
The original LibTIFF for C/C++ can be found at http://www.remotesensing.org/libtiff/ which may help you with documentation and support if needed.
Included with libTiff is a program called tiffCrop which should also have source code. http://www.remotesensing.org/libtiff/man/tiffcrop.1.html which can be accessed via
http://www.remotesensing.org/libtiff/tools.html.
See here.
I'm having issues with TIFFs
Here is what I have to do, we have tiff images saved into the database, these images are CCITT4 compressed with a number of required tags, these include:
RowsPerStrip must be the ImageLength
Photometric Interpreation must be MinIsWhite
Multi-strip image format is not allowed
My problem is, I'm using the built in System.Drawing.Bitmap/Image objects, which happen to change the values of these when I put it into the object, I've tested this by saving the byte[] to a tiff directly from the database, checked the tags, they are fine.. but when i put the bytes into an Image object then save to file, they are modified.
To make things worse, I'm needing to add a text to the image before saving it.
So I need a component that will allow me more control with TIFF (and they must be tiff), and be able to add text to an image or be able to use the Graphics object.
I've tried using LibTiff but I have yet to see any examples on how to use this component,
any suggestions?
You can use our free and open-source LibTiff.Net library for this. It is freely available for all uses under a BSD license. The just released version 2.0 contains good documentation and number of samples.
There are samples that show how to convert any non-tiled TIFF image to the TIFF image which have all data written in a single strip and how to convert a System.Drawing.Bitmap to 1-bit CCITT single strip TIFF image.
I have never used the built int System.Drawing.Bitmap objects to do this. I personally use LeadTools, but it isn't free. It is however a robust and fairly straightforward API. I primarily use it for GEOTiff which contain specific data tags for image location data.
There is a 60 day evaluation if you would like to try it out.
I use FreeImage. There's a C# .NET wrapper available too.
The IEvolution component set from HiComponents is now totally free (no source) - http://www.hicomponents.com. A very powerful .NET imaging toolkit.