[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

le_mo_mo

10/18/2004 12:28:00 AM

Hi,
What is wrong with this code. the file generated is about half the
size of original and is corrupted.

System.Drawing.Image imgsource=System.Drawing.Image.FromStream(new
system.IO.MemoryStream(filMyFile.PostedFile));
Double xRatio; Double yRatio; Int32 newWidth; Int32 newHeight;

xRatio=1; yRatio=1;
newWidth = (Int32)System.Math.Round(source.Width * xRatio);
newHeight = (Int32)System.Math.Floor(source.Height * yRatio);

System.Drawing.Image newimage =
imgsource.GetThumbnailImage(newWidth,newHeight,null,IntPtr.Zero);

MemoryStream ms = new MemoryStream();
ImageFormat thisformat=newimage.RawFormat;
Bitmap imagebitmap = new Bitmap(newimage,newWidth,newHeight);
imagebitmap.Save(ms,ImageFormat.Jpeg);
ms.Seek(0,SeekOrigin.Begin);
byte[] SmallmyData = new byte[ms.Length];

FileStream newFile = new FileStream(strPath, FileMode.Create);
newFile.Write(SmallmyData, 0, SmallmyData.Length);
newFile.Close();

Thanks