954,518 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Help Resizing Image, PLEASE!!

Hey guys, I'm hoping someone can gelp me try to get a snipet of code working that i've been having problems with. What I'm trying to accomplish is to get a picture from a users computer with ASP.net with a C# backend, convert that picture to an System.Drawing.Image so I can then use GDI in order to resize the image, save it as a JPG, and then convert it to a stream so I can pipe it out to my database. The code I have currently, although it doesn't throw any build errors or runtime errors, it just simply doesn't work.

If anyone can see something wrong, or has a suggestion of a different way to do it, please let me know.

Thanks!!

if(pic.PostedFile != null)
{
string picType = pic.PostedFile.ContentType.ToString();
int picSize = pic.PostedFile.ContentLength;
							
								System.Drawing.Image picTemp = System.Drawing.Image.FromStream(pic.PostedFile.InputStream);
								
								System.Drawing.Image imgPhototemp = FixedSize(picTemp, 200, 250);
								
MemoryStream picStream = new MemoryStream();

								imgPhototemp.Save(picStream,System.Drawing.Imaging.ImageFormat.Jpeg);

int picLength = (int)picStream.Length;
byte[] picBuffer = new byte[picLength];
									
								picStream.Read(picBuffer,0,picLength);
						
addRow.Pic = picBuffer;
}
aaj23
Newbie Poster
2 posts since Mar 2006
Reputation Points: 10
Solved Threads: 0
 

Not sure but here is an article where you can take hints from

http://www.csharp-station.com/Articles/Thumbnails.aspx

chrisranjana
Junior Poster in Training
83 posts since Jul 2005
Reputation Points: 11
Solved Threads: 3
 

Go to asp.net's forum great stuff there.

cheers'
jamesonh20

jamesonh20
Junior Poster in Training
66 posts since Dec 2009
Reputation Points: 22
Solved Threads: 6
 

Go to asp.net's forum great stuff there.

cheers' jamesonh20

You're almost 4 years late, but thanks for the heads up...lol.

aaj23
Newbie Poster
2 posts since Mar 2006
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You