Aj

Aj

  • NA
  • 1
  • 0

Image Resize Help PLEASE!!

Mar 12 2006 4:37 PM
Hey guys, I'm new to this forum, and was hoping to get some help. I'm using ASP.net with a C# back end and I'm having problems with some code I'm trying to get to work. What this code does, or what I want it to do is to grab a pic from a users computer where they specify, convert that file into a System.Drawing.Image file so that I can use GDI in order to resize it, and then bring it back from my resize function in order to save it as a jpg and then stream it out to my database. Can anyone look at this code snipet and see if they see something wrong with it (it doesn't throw any errors while being built or even at runtime, it just shows a red "x" where the pic should be. If no one is familiar with this type of code, perhaps someone can suggest how I could resize the image before it hits my database without saving anything on the users computer even temporarily. 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; }