error converting image from tif to jpg format 
Author Message
 error converting image from tif to jpg format
Hi All:

I am trying to convert an image from "tif" format to "jpg"
format using C#. I've tried 2 different approaches to this
and I always get the following error:

"System.Runtime.InteropServices.ExtendException"
"A generic error occurred in GDI++".

Here are my two approaches:

1)
Image jpgImage;
jpgImage = Image.FromFile(newPhotos[i]);
jpgImage.Save
("C:\temp\test.jpg",System.Drawing.Imaging.ImageFormat.Jpeg
);

2)
Bitmap bitmap = new Bitmap(newPhotos[i]); //NewPhotos has
the path
bitmap.Save
("C:\temp\test.jpg",System.Drawing.Imaging.ImageFormat.Jpeg
);

What am I doing wrong? Any ideas are greatly appreciated.
Thanks!

Mike



Mon, 30 May 2005 08:08:09 GMT  
 error converting image from tif to jpg format
I figured out what I was doing wrong. In the path name
where I save the photo I had backslashes, which are escape
characters in C# (unlike VB). When I changed the path as
shown below it worked fine:

original path:  C:\temp\test.jpg

Mike

Quote:
>-----Original Message-----
>Hi All:

>I am trying to convert an image from "tif" format
to "jpg"
>format using C#. I've tried 2 different approaches to
this
>and I always get the following error:

>"System.Runtime.InteropServices.ExtendException"
>"A generic error occurred in GDI++".

>Here are my two approaches:

>1)
>Image jpgImage;
>jpgImage = Image.FromFile(newPhotos[i]);
>jpgImage.Save

("C:\temp\test.jpg",System.Drawing.Imaging.ImageFormat.Jpeg
Quote:
>);

>2)
>Bitmap bitmap = new Bitmap(newPhotos[i]); //NewPhotos has
>the path
>bitmap.Save

("C:\temp\test.jpg",System.Drawing.Imaging.ImageFormat.Jpeg

- Show quoted text -

Quote:
>);

>What am I doing wrong? Any ideas are greatly appreciated.
>Thanks!

>Mike

>.



Tue, 31 May 2005 06:44:50 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Converting word .doc file into .tif image format

2. Anyone have routine to convert tif to jpg?

3. How to pass a .tif image to the DIB(Device Independent Bitmap) format

4. Code to convert images to *.RAW format

5. Help: Convert B/W image in BMP format to 0-255 grey scale

6. Fastest way to load TIF image ?

7. display tif image

8. reading TIF images

9. Fastest way to Load TIF image ?

10. picture formats for BMP, TIF, GIF etc.

11. .tif/.vif file format

12. I need help to convert TXT file(s) to TIF file(s)

 

 
Powered by phpBB® Forum Software