I'm reading the file in out of my hard drive. I think run
the
ConvertStringToByteArray which converts it to a Byte[]. I
then try to
convert the Byte[] into the image.
StreamReader sr = new StreamReader(outFilePathAndName);
convertedImage = ConvertStringToByteArray(sr.ReadToEnd());
public static Byte[] ConvertStringToByteArray(string
stringToConvert)
{
return (new
UnicodeEncoding()).GetBytes(stringToConvert);
}
Shawn Hevel, API, AIT
Lead Programmer Analyst
Information Technology Department
South Carolina Farm Bureau Insurance Companies
Phone: (803) 936-4331
Fax: (803) 936-4629
Work Email: shawnhevel scfbins.com
Home Email: hevelhouse sc.rr.com
-----Original Message-----
From: Shawn Wildermuth [mailto:swildermuth.lists ADOGUY.COM]
Sent: Friday, January 05, 2007 12:48 PM
To: ADVANCED-DOTNET DISCUSS.DEVELOP.COM
Subject: Re: [ADVANCED-DOTNET] Conversion Error
Is this byte array coming from a database table? (e.g. an
Image column)?
Thanks,
Shawn Wildermuth
Wildermuth Consulting Services, LLC
http://adoguy.com
C# MVP, MCSD.NET, Author and Speaker
-----Original Message-----
From: Discussion of advanced .NET topics.
[mailto:ADVANCED-DOTNET DISCUSS.DEVELOP.COM] On Behalf Of Hevel,
Shawn
Sent: Friday, January 05, 2007 9:23 AM
To: ADVANCED-DOTNET DISCUSS.DEVELOP.COM
Subject: [ADVANCED-DOTNET] Conversion Error
I'm trying to convert a System.Byte[] into
System.Drawing.Image. I've
included my code below. When I execute
System.Drawing.Image.FromStream(ms)
I get the following error: System.ArgumentException:
Parameter is not
valid. Does anyone have an idea as to why this is throwing
an error?
public System.Drawing.Image ByteArrayToImage(Byte[]
byteArrayIn)
{
MemoryStream ms = new MemoryStream(byteArrayIn);
System.Drawing.Image returnImage =
System.Drawing.Image.FromStream(ms);
return returnImage;
}
Thanks,
Shawn Hevel, API, AIT
Lead Programmer Analyst
Information Technology Department
South Carolina Farm Bureau Insurance Companies
Phone: (803) 936-4331
Fax: (803) 936-4629
Work Email: shawnhevel scfbins.com <mailto:ShawnHevel scfbins.com>
Home Email: hevelhouse sc.rr.com
===================================
This list is hosted by DevelopMentor® http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com
===================================
This list is hosted by DevelopMentor® http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com
===================================
This list is hosted by DevelopMentor® http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com
|