0
加載代碼我的形象不是由文件系統壓縮
var memoryStream = new MemoryStream();
using (memoryStream)
{
System.Web.HttpContext.Current.Request.Files[upload].InputStream.CopyTo(memoryStream);
memoryStream.ToArray();
}
byte[] bytes = memoryStream.GetBuffer();
// Get the image from the server
System.Drawing.Image image = new System.Drawing.Bitmap(System.Web.HttpContext.Current.Request.Files[upload].InputStream);
調整圖像調用:
System.Drawing.Image image = this.ResizeImage(
image,
originalImagePath,
ImageSizeType.Original,
null,
null)
保存圖像調用:
image.Save(<location to save>);
不壓縮圖像的代碼:
private System.Drawing.Image ResizeImage(System.Drawing.Image image, string filePath, string sizeType, int? _width, int? height)
{
...
System.Drawing.Bitmap b = new System.Drawing.Bitmap(width, resizeHeight);
b.SetResolution(72, 72);
System.Drawing.Graphics g = System.Drawing.Graphics.FromImage((System.Drawing.Image)b);
g.CompositingQuality = CompositingQuality.HighSpeed;
//g.InterpolationMode = InterpolationMode.HighQualityBicubic;
g.InterpolationMode = InterpolationMode.Low;
g.SmoothingMode = SmoothingMode.HighSpeed;
g.DrawImage(image, 0, 0, width, resizeHeight);
g.Dispose();
return (System.Drawing.Image)b;
}
不管我做什麼,以這個形象,當它保存,這樣可以節省在真的很高。
例如...爲1024×768 @ 300KB JPG格式變成600×400 @ 800KB
我在做什麼錯?
什麼是原始和調整大小的文件格式?您不顯示加載/保存代碼。 – GazTheDestroyer
保存文件的格式是? – Magnus
png,gif,jpg ...任何真的。無論用戶上傳 – Jimmyt1988