Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / Drawing / October 2005

Tip: Looking for answers? Try searching our database.

image.fromstream throws argument exception. Urgent

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Peter - 25 Oct 2005 04:39 GMT
I have asp.net code using C# that will convert tif file into jpg and then it
display them. The program works on my machine and Dev machine with Window XP
professional. When I deploy the program on test machine (window 2003 server)
I get error:

Argument Exception Invalid parameter used"

The code that causes the error is:

byte[] imgbyte;
MemoryStream memStream = new MemoryStream(imgByte.Length);
memStream.Write(imgByte, 0 , imgByte.Length);
System.Drawing.Image.FromStream(memStream);

the error happen at Image.FromStream() method.

I tried different ways and searched google without success.  Also, I tried
Image.FromFile() where I got "out of memory exception" error.

Is window 2003 cause of this problem?
How I know if GDI+ is installed on window 2003?
Does the dell generated by visual studio .net include the GDI+ dll?

I would appreciate any help in this matter. Thanks

Any help to resolve the issue
I do not know why it does not work on test machine today. It works on my
machine and it worked on test machine previously. I appreciate any help to
resolve this problem. Thanks
Michael Phillips, Jr. - 25 Oct 2005 14:34 GMT
> memStream.Write(imgByte, 0 , imgByte.Length);

The above statement positions the stream pointer at the
end of the image.

Try setting the stream pointer to the beginning of the
image before calling System.Drawing.Image.FromStream(memStream);

>I have asp.net code using C# that will convert tif file into jpg and then
>it
[quoted text clipped - 28 lines]
> machine and it worked on test machine previously. I appreciate any help to
> resolve this problem. Thanks
Peter - 26 Oct 2005 14:18 GMT
I have put the statment to set the position of stream at 0 without any
effect. I read on microsoft web site that there is a bug in GDI+ that causes
the mentioned error. GDI+ cannot handle 24 bits and 16 bits tif files. I have
4 bits gray scale tif image. Any idea? Thanks

> > memStream.Write(imgByte, 0 , imgByte.Length);
>
[quoted text clipped - 36 lines]
> > machine and it worked on test machine previously. I appreciate any help to
> > resolve this problem. Thanks
Michael Phillips, Jr. - 26 Oct 2005 15:39 GMT
I tried loading 4bpp, 16bpp and 24bpp grayscale tiff files and converted
them without error to jpeg images.

You can not use the same stream that you loaded the tiff files
to save the jpeg files.  They must be separate streams.

>I have put the statment to set the position of stream at 0 without any
> effect. I read on microsoft web site that there is a bug in GDI+ that
[quoted text clipped - 48 lines]
>> > to
>> > resolve this problem. Thanks

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.