| | |
Help Resizing Image, PLEASE!!
Please support our C# advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
![]() |
•
•
Join Date: Mar 2006
Posts: 1
Reputation:
Solved Threads: 0
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;
}
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;
}
•
•
Join Date: Jul 2005
Posts: 78
Reputation:
Solved Threads: 3
Not sure but here is an article where you can take hints from
http://www.csharp-station.com/Articles/Thumbnails.aspx
http://www.csharp-station.com/Articles/Thumbnails.aspx
Chris, Director, Chrisranjana.com
Web developers and software programmers.
Web developers and software programmers.
![]() |
Similar Threads
- Code for Image Processing (C)
- Web management / rates (eCommerce)
- how does this work? (JavaScript / DHTML / AJAX)
- Auto replace hotlinked Image Javascript? (JavaScript / DHTML / AJAX)
- Scrollbar help? (JavaScript / DHTML / AJAX)
- Thumbnailed images (PHP)
- Image Resize Function Error (PHP)
- auto image resizing (Mac tips 'n' tweaks)
Other Threads in the C# Forum
- Previous Thread: image manipulation
- Next Thread: counting files on a drive
| Thread Tools | Search this Thread |
.net access algorithm animation array asp avltree bitmap box c# check checkbox client column combobox control conversion csharp database datagrid datagridview datagridviewcheckbox dataset datetime degrees directrobot display draganddrop drawing encryption enum equation excel file form format formatting formbox forms formupdate function gdi+ hash image input install java leak linux list math mouseclick mp3 mysql namevaluepairs native networking operator packaging path photoshop picturebox pixelinversion post powerpacks print process programming radians regex remoting reporting richtextbox robot safari server sleep snooze socket sql statistics string table tables tcp text textbox thread time timer update usercontrol usercontrols validation visualstudio webbrowser wfa winforms wpf xml





