| | |
Help Resizing Image, PLEASE!!
Please support our C# advertiser: Intel Parallel Studio Home
![]() |
•
•
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 2007 access activedirectory algorithm array barchart bitmap box broadcast c# check checkbox client combobox control conversion cryptographyc#winformsencryption csharp custom database datagrid datagridview dataset date datetime degrees development disabled displayingopenforms draganddrop drawing encryption enum eventcloseformc# excel file foreach form format forms ftp function gdi+ image index index-error input install java label list listbox listener listview load mandelbrot math mathematics mouseclick mysql operator path photoshop picturebox pixelinversion post prime programming radians regex remoting richtextbox security server setup sleep socket sql statistics stream string table text textbox thread time timer totaldays update user usercontrol validation visual visualstudio webbrowser windows winforms wpf xml





