我把新东西用在像样子中,因此我需要一些帮助,以解决这个问题。
基本想法是:
- get image from QueryString, for example: /Default.aspx?src=http://www.google.hr/images/logo.png
- convert it and resize to 16x16 px ".ico" IE compilant
- save it to server, and print/echo URL to ico
Using ASP.NET 3.5 C# This is my try:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Drawing;
using System.IO;
using System.Net;
namespace WebApplication2
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
var source = Request.QueryString["src"];
if (source != null)
{
WebClient webclient = new WebClient();
using (Stream stream = webclient.OpenRead(source))
{
Bitmap iconbitmap = new Bitmap(System.Drawing.Image.FromFile(webclient));
var icon = Icon.FromHandle((iconbitmap).GetHicon());
FileStream fs = new FileStream("/test1.ico", FileMode.Create);
icon.Save(fs);
fs.Close();
}
}
}
}
}
EDIT:
Got some errors (Error 1 The best overloaded method match for System.Drawing.Image.FromFile(string) has some invalid arguments )
增 编