Image Conversion in C#

D

Dilmurat Sulayman

Hi,

I have a jpg image. Now, I'm going to put some text and merge it with other
emf file. So, I converted it to emf file with Image.Save. but I couldn't
load it.

My code is:

Image imgFile = Image.FromFile("test.jpg");
imgFile.Save("test.emf"), ImageFormat.Emf);
Metafile Img1 = (Metafile)Image.FromFile( "test.emf" );

and it gives me following error on the latest line.

Exception Details: System.Runtime.InteropServices.ExternalException: A
generic error occurred in GDI+.

have any idia on it?

Thanks,

Dil
 
S

sloan

There's about 1000 reasons what that happens.

Make sure you have write privledges to the directory. That one gets
overlooked alot.

I doubt thats your issue.
 
K

Ken Cox [Microsoft MVP]

Hi Dil,

There's a syntax error in the second line. I was able to create the emf file
like this:

System.Drawing.Image imgFile =
System.Drawing.Image.FromFile(Server.MapPath("test.jpg"));
imgFile.Save(Server.MapPath("test.emf"),
System.Drawing.Imaging.ImageFormat.Emf);


*However*, did you see this?

"When you use the Save method to save a graphic image as a Windows Metafile
Format (WMF) or Enhanced Metafile Format (EMF) file, the resulting file is
saved as a Portable Network Graphics (PNG) file instead. This behavior
occurs because the GDI+ component of the .NET Framework does not have an
encoder that you can use to save files as .wmf or .emf files."

http://msdn2.microsoft.com/en-us/library/ktx83wah.aspx

Ken
Microsoft MVP [ASP.NET]
 
C

C# Dev

Thanks, Ken,
I really didn't see that before.
Is there any way to conver jpg to emf, and load it in C#?

Many thanks,

Dil
 
S

Steve B.

if emf is vector based picture, you won't be able to save an image to a
bitmap format, which is pixel based format.
 
C

C# Dev

File is jpg format, not emf. What I want to do is to convert jpg image to
emf file.

Dil

******************
if emf is vector based picture, you won't be able to save an image to a
bitmap format, which is pixel based format.


"C# Dev" a crit dans le message de (e-mail address removed)...
Thanks, Ken,
I really didn't see that before.
Is there any way to conver jpg to emf, and load it in C#?

Many thanks,

Dil

***************************
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top