ASPJPEG读post传过来的图片问题
大家帮帮我啊!我这里有个程序,需要接收post传过来的图片数据,并采用ASPJPEG压缩,现在的问题是:采用System.Drawing.Image可以将POST过来的图片接收,但是我不会将这个接收的数据传递给ASPJPEG,只能先存到服务器硬盘上,然后再用ASPJPEG打开后压缩,这样就多了个存储到服务器上的过程,现在大家帮帮我看看怎么直接用ASPJPEG接收这个图片文件啊! 我试过了ASPJPEG网站上的方法(objJpeg.Open( Request["path"] ),但是不管用,有错误,怎么解决呢?
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Collections.Generic;
public partial class upload : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
System.Drawing.Image original_image = null;
try
{
// Get the data
string file_id = Request.QueryString["file_id"] as string;
HttpPostedFile jpeg_image_upload = Request.Files["Filedata"];
//creat aspjpeg project
ASPJPEGLib.IASPJpeg objJpeg;
objJpeg = new ASPJPEGLib.ASPJpeg();
// Retrieve the uploaded image
original_image = System.Drawing.Image.FromStream(jpeg_image_upload.InputStream);
//先保存到服务器上
string picpath = Server.MapPath("images/1.jpg");
original_image.Save(picpath, System.Drawing.Imaging.ImageFormat.Jpeg);
//重新打开
objJpeg.Open(picpath);
//删除服务器上的较大的图片文件
File.Delete(Server.MapPath("images/1.jpg"));
// Resizing is optional. None in this code sample.
if (objJpeg.Width / objJpeg.Height >= 1)
{
objJpeg.Width = 400;
objJpeg.Height = objJpeg.OriginalHeight * objJpeg.Width / objJpeg.OriginalWidth;
}
else
{
objJpeg.Height = 400;
objJpeg.Width = objJpeg.OriginalWidth * objJpeg.Height / objJpeg.OriginalHeight;
}
objJpeg.Canvas.DrawBar(1, 1, objJpeg.Width, objJpeg.Height);
objJpeg.Save(Server.MapPath("images/1_new.jpg"));
}
catch
{
// If any kind of error occurs return a 500 Internal Server error
Response.StatusCode = 500;
Response.Write("An error occured");
Response.End();
}
finally
{
// Clean up
if (original_image != null) original_image.Dispose();
}
}
}
大家看看帮帮我吧!
--------------------编程问答-------------------- 没有人知道吗,急死我了。这样做对吗?
补充:.NET技术 , ASP.NET