日期:2014-05-18  浏览次数:20454 次

asp.net 2.0问题大集合求解!!每问50分
一、JPEG/GIF/PNG图片上传并自动生成高质量可控制宽、高、分辨率、加水印的图片解决方案!!(45分)
二、通过后台控制网站开放、暂停的解决方案!!要求:网站暂停后可以直接输入网站后台地址进行调整。前台页面不可访问,通过app_offline似乎是对整个网站进行控制,效果不理想(10分)
三、网站会员权限管理解决方案,网络上大多是基于asp.net+sql   server的membership,依赖于sql   server数据库,现在要求通用于Access数据库代码,通过不同权限管理不同网站模块。(45分)

说明:
        可以提供源码或精彩的参考网址,只要有非常高的参考价值都给分。
        同时也欢迎大家热热讨论!!如果分不够。可以另开贴加分!!绝不食言。
     


------解决方案--------------------
一、JPEG/GIF/PNG图片上传并自动生成高质量可控制宽、高、分辨率、加水印的图片解决方案!!(45分)
----------------------------------------------
这个方法应该能满足的:
/// <summary>
/// 按比例生成缩略图(以Stream方式获取源文件)
/// </summary>
/// <param name= "fromFileStream "> 原图Stream </param>
/// <param name= "fileSaveUrl "> 缩略图存放地址 </param>
/// <param name= "templateWidth "> 指定的最大宽度 </param>
/// <param name= "templateHeight "> 指定的最大高度 </param>
public static void MakeSmallImg(System.IO.Stream fromFileStream, string fileSaveUrl, System.Double templateWidth, System.Double templateHeight)
{
//从文件取得图片对象,并使用流中嵌入的颜色管理信息
System.Drawing.Image myImage = System.Drawing.Image.FromStream(fromFileStream, true);
//缩略图宽、高
System.Double newWidth = myImage.Width, newHeight = myImage.Height;
//宽大于模版的横图
if (myImage.Width > myImage.Height || myImage.Width == myImage.Height)
{
if (myImage.Width > templateWidth)
{
//宽按模版,高按比例缩放
newWidth = templateWidth;
newHeight = myImage.Height * (newWidth / myImage.Width);
}
}
//高大于模版的竖图
else
{
if (myImage.Height > templateHeight)
{
//高按模版,宽按比例缩放
newHeight = templateHeight;
newWidth = myImage.Width * (newHeight / myImage.Height);
}
}
//取得图片大小
System.Drawing.Size mySize = new Size((int)newWidth, (int)newHeight);
//新建一个bmp图片
System.Drawing.Image bitmap = new System.Drawing.Bitmap(mySize.Width, mySize.Height);
//新建一个画板
System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bitmap);
//设置高质量插值法
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;
//设置高质量,低速度呈现平滑程度
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
//清空一下画布
g.Clear(Color.White);
//在指定位置画图
g.DrawImage(myImage, new System.Drawing.Rectangle(0, 0, bitmap.Width, bitmap.Height), new System.Drawing.Rectangle(0, 0, myImage.Width, myImage.Height), System.Drawing.GraphicsUnit.Pixel);
///文字水印
//System.Drawing.Graphics G=System.Drawing.Graphics.FromImage(bitmap);
//System.Drawing.Font f=new Font( "宋体 ",10);
//System.Drawing.Brush b=new SolidBrush(Color.Black);
//G.DrawString( "myohmine ",f,b,10,10);
//G.Dispose();
///图片水印
//System.Drawing.Image copyImage = System.Drawing.Image.FromFile(System.Web.HttpContext.Current.Server.MapPath( "pic/1.gif "));
//Graphics a = Graphics.