Image Conversion in C#

Discussion in 'ASP .Net' started by Dilmurat Sulayman, Jun 26, 2006.

  1. 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
     
    Dilmurat Sulayman, Jun 26, 2006
    #1
    1. Advertising

  2. Dilmurat Sulayman

    sloan Guest

    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" <> wrote in message
    news:...
    > 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
     
    sloan, Jun 27, 2006
    #2
    1. Advertising

  3. 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" <> wrote in message
    news:...
    > 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
     
    Ken Cox [Microsoft MVP], Jun 27, 2006
    #3
  4. Dilmurat Sulayman

    C# Dev Guest

    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
     
    C# Dev, Jun 27, 2006
    #4
  5. Dilmurat Sulayman

    Steve B. Guest

    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:
    ...
    > 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
     
    Steve B., Jun 27, 2006
    #5
  6. Dilmurat Sulayman

    C# Dev Guest

    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:
    ...
    > 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


    ***************************
     
    C# Dev, Jun 27, 2006
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?RGVhc3Vu?=

    Conversion issue: Image>Byte array>Image

    =?Utf-8?B?RGVhc3Vu?=, Jul 14, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    923
    =?Utf-8?B?RGVhc3Vu?=
    Jul 14, 2005
  2. surendra
    Replies:
    1
    Views:
    8,508
    dipakPardesi
    Jun 21, 2008
  3. Roland
    Replies:
    0
    Views:
    1,096
    Roland
    May 12, 2004
  4. Laszlo Zsolt Nagy
    Replies:
    1
    Views:
    1,432
    Kartic
    Jan 26, 2005
  5. , India
    Replies:
    2
    Views:
    506
    Fraser Ross
    Sep 15, 2009
Loading...

Share This Page