English 中文(简体)
• 与ASP一起恢复图像。 NET和数据库储蓄
原标题:Resizing Images with ASP.NET and saving to Database

我需要掌握上载的形象,转播图像,将其节省到数据库。 简言之,除我没有机会向服务器节省任何时间档案外。 I m 拍摄图像,将图像做成比图,需要将其保存到数据库领域,作为原始图像类型(例如JPG)。 我怎么能这样获得档案馆,以便我能将其留给数据库?

在我使用图象上载之前,FileBytes()但现在,我转而处理图像和比特图的Im,而不是文件上载,似乎可以发现任何会给我带来的东西。

感谢!

最佳回答

Resizing an Value同时又不丧失任何质量。 然后,你可以把你的形象(Bitmap.Save ToStream)写到记忆犹新,并叫ToArray去接受tes。

问题回答

这是我为改变形象所做的事。

    private byte[] toBytes(Image image)
    {            
        Bitmap resized = new Bitmap(image, yourWidth, yourHeight);            
        System.IO.MemoryStream ms = new System.IO.MemoryStream();            
        resized.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
        resized.Dispose();
        return ms.ToArray();            
    }




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签