473,396 Members | 1,810 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Image Conversion in C#

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
Jun 26 '06 #1
5 6979
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.
"Dilmurat Sulayman" <di****@yahoo.com> wrote in message
news:90******************************@ureader.com. ..
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

Jun 27 '06 #2
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]
"Dilmurat Sulayman" <di****@yahoo.com> wrote in message
news:90******************************@ureader.com. ..
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

Jun 27 '06 #3
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
Jun 27 '06 #4
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" <di****@yahoo.com> a écrit dans le message de news:
13******************************@ureader.com...
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

Jun 27 '06 #5
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 news:
13******************************@ureader.com...
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


***************************
Jun 27 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Ian.H | last post by:
Hi all, I don't have ImageMagick installed currently (and not sure if this has the ability or not anyway yet), but I've done some googling and not come up with much (if anything) regarding this....
7
by: Useko Netsumi | last post by:
Hi, suppose I'd like to convert my JPG images(in a directory) into a lower resolution and uniform size(while maintaining its aspect ratio), I would I do that in PHP? I've seen code with PHP/GD...
3
by: alastair | last post by:
Hi, I need to convert a 24-bit RGB TIFF image to an 8-bit RGB TIFF image. I've tried using PIL and the convert() method - this allowed me to convert to an 8-bit grayscale image, close but not...
0
by: Mark | last post by:
We're authoring a VS 2005 app that includes several EXE's and DLL's and also uses a COM component (a customer requirement). The COM component provides a graphic image to be used by the .NET app;...
4
by: Mark | last post by:
We're authoring a VS 2005 app that includes several EXE's and DLL's and also uses a COM component (a customer requirement). The COM component provides a graphic image to be used by the .NET app;...
0
by: arun | last post by:
Hi, I have a tif image, that can't be open by any type of tif viewers. Some sort of data is missing. I want to read that file (using any type of conversion - ie tif to gif or binary...
0
by: Craig | last post by:
Hi there, This could be a curly question. When I created the x11 bitmap image using the im.tobitmap() function I found out later that the display information in the array is big endian (I...
5
by: massimoal | last post by:
Hi all, I need to convert a tif image, grabbed by a pixelink industrial camera, to a text file (1024x768 elements) but I really don't know how. Surfing the net I found that there are a lot of...
2
by: jithesh82 | last post by:
Hi, I am a Research Scholoar working in the area of nanotechnology. I have some STM pictures taken about a few years back my Professor. The problem is that the images are of some unsual...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.