【问题标题】:how to make image as downloadable from database in asp.net,C#如何使图像可从asp.net,C#中的数据库下载
【发布时间】:2015-12-02 20:35:13
【问题描述】:

我将图像以二进制格式保存到数据库中,并在检索时将该二进制格式转换为图像文件并显示。

byte[] picbin = (byte[])(binary data in datbase);
ImageConverter ic = new ImageConverter();
System.Drawing.Image img = (System.Drawing.Image)ic.ConvertFrom(picbin);`

并通过给出一些名称将 img- 变量保存到某个文件夹中。但现在我需要能够以任何一种格式向用户提供该特定图像的“可下载选项”,以便用户可以验证它,那么实现这一点的方法是什么。

【问题讨论】:

  • 您有什么理由不想只以原始格式提供它?用户真的需要不同的格式吗?

标签: c# asp.net image


【解决方案1】:

要将图像转换为不同的格式:

// Save the image in JPEG format.
img.Save(@"C:\test.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);

// Save the image in GIF format.
img.Save(@"C:\test.gif", System.Drawing.Imaging.ImageFormat.Gif);

// Save the image in PNG format.
img.Save(@"C:\test.png", System.Drawing.Imaging.ImageFormat.Png);    

查看How to: Convert Images from One Format to Another

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-10
    相关资源
    最近更新 更多