DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   C# (http://www.daniweb.com/forums/forum61.html)
-   -   Help Resizing Image, PLEASE!! (http://www.daniweb.com/forums/thread40984.html)

aaj23 Mar 12th, 2006 5:28 pm
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;
}

chrisranjana Apr 3rd, 2006 9:50 am
Re: Help Resizing Image, PLEASE!!
 
Not sure but here is an article where you can take hints from

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


All times are GMT -4. The time now is 9:02 am.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC